summaryrefslogtreecommitdiffstats
path: root/tests/run-make
diff options
context:
space:
mode:
Diffstat (limited to 'tests/run-make')
-rw-r--r--tests/run-make/comment-section/Makefile15
-rw-r--r--tests/run-make/compressed-debuginfo/Makefile14
-rw-r--r--tests/run-make/compressed-debuginfo/foo.rs3
-rw-r--r--tests/run-make/const_fn_mir/Makefile7
-rw-r--r--tests/run-make/const_fn_mir/dump.mir35
-rw-r--r--tests/run-make/coverage-llvmir/Makefile2
-rw-r--r--tests/run-make/coverage-llvmir/filecheck.testprog.txt10
-rw-r--r--tests/run-make/coverage-reports/Makefile178
-rw-r--r--tests/run-make/coverage-reports/expected_show_coverage.abort.txt69
-rw-r--r--tests/run-make/coverage-reports/expected_show_coverage.assert.txt34
-rw-r--r--tests/run-make/coverage-reports/expected_show_coverage.async.txt139
-rw-r--r--tests/run-make/coverage-reports/expected_show_coverage.async2.txt116
-rw-r--r--tests/run-make/coverage-reports/expected_show_coverage.closure.txt222
-rw-r--r--tests/run-make/coverage-reports/expected_show_coverage.closure_macro.txt42
-rw-r--r--tests/run-make/coverage-reports/expected_show_coverage.closure_macro_async.txt83
-rw-r--r--tests/run-make/coverage-reports/expected_show_coverage.conditions.txt94
-rw-r--r--tests/run-make/coverage-reports/expected_show_coverage.continue.txt70
-rw-r--r--tests/run-make/coverage-reports/expected_show_coverage.dead_code.txt39
-rw-r--r--tests/run-make/coverage-reports/expected_show_coverage.doctest.txt115
-rw-r--r--tests/run-make/coverage-reports/expected_show_coverage.drop_trait.txt34
-rw-r--r--tests/run-make/coverage-reports/expected_show_coverage.generator.txt32
-rw-r--r--tests/run-make/coverage-reports/expected_show_coverage.generics.txt71
-rw-r--r--tests/run-make/coverage-reports/expected_show_coverage.if.txt30
-rw-r--r--tests/run-make/coverage-reports/expected_show_coverage.if_else.txt41
-rw-r--r--tests/run-make/coverage-reports/expected_show_coverage.inline-dead.txt28
-rw-r--r--tests/run-make/coverage-reports/expected_show_coverage.inline.txt54
-rw-r--r--tests/run-make/coverage-reports/expected_show_coverage.inner_items.txt60
-rw-r--r--tests/run-make/coverage-reports/expected_show_coverage.issue-83601.txt16
-rw-r--r--tests/run-make/coverage-reports/expected_show_coverage.issue-84561.txt189
-rw-r--r--tests/run-make/coverage-reports/expected_show_coverage.issue-85461.txt36
-rw-r--r--tests/run-make/coverage-reports/expected_show_coverage.issue-93054.txt29
-rw-r--r--tests/run-make/coverage-reports/expected_show_coverage.lazy_boolean.txt64
-rw-r--r--tests/run-make/coverage-reports/expected_show_coverage.loop_break_value.txt14
-rw-r--r--tests/run-make/coverage-reports/expected_show_coverage.loops_branches.txt68
-rw-r--r--tests/run-make/coverage-reports/expected_show_coverage.match_or_pattern.txt50
-rw-r--r--tests/run-make/coverage-reports/expected_show_coverage.nested_loops.txt26
-rw-r--r--tests/run-make/coverage-reports/expected_show_coverage.no_cov_crate.txt87
-rw-r--r--tests/run-make/coverage-reports/expected_show_coverage.overflow.txt64
-rw-r--r--tests/run-make/coverage-reports/expected_show_coverage.panic_unwind.txt32
-rw-r--r--tests/run-make/coverage-reports/expected_show_coverage.partial_eq.txt48
-rw-r--r--tests/run-make/coverage-reports/expected_show_coverage.simple_loop.txt37
-rw-r--r--tests/run-make/coverage-reports/expected_show_coverage.simple_match.txt45
-rw-r--r--tests/run-make/coverage-reports/expected_show_coverage.sort_groups.txt49
-rw-r--r--tests/run-make/coverage-reports/expected_show_coverage.test_harness.txt11
-rw-r--r--tests/run-make/coverage-reports/expected_show_coverage.tight_inf_loop.txt6
-rw-r--r--tests/run-make/coverage-reports/expected_show_coverage.try_error_result.txt125
-rw-r--r--tests/run-make/coverage-reports/expected_show_coverage.unused.txt62
-rw-r--r--tests/run-make/coverage-reports/expected_show_coverage.unused_mod.txt4
-rw-r--r--tests/run-make/coverage-reports/expected_show_coverage.uses_crate.txt148
-rw-r--r--tests/run-make/coverage-reports/expected_show_coverage.uses_inline_crate.txt139
-rw-r--r--tests/run-make/coverage-reports/expected_show_coverage.while.txt6
-rw-r--r--tests/run-make/coverage-reports/expected_show_coverage.while_early_ret.txt43
-rw-r--r--tests/run-make/coverage-reports/expected_show_coverage.yield.txt38
-rwxr-xr-xtests/run-make/coverage-reports/normalize_paths.py12
-rw-r--r--tests/run-make/coverage-reports/sort_subviews.py50
-rw-r--r--tests/run-make/coverage/WARNING_KEEP_NAMES_SHORT.txt10
-rw-r--r--tests/run-make/coverage/abort.rs66
-rw-r--r--tests/run-make/coverage/assert.rs32
-rw-r--r--tests/run-make/coverage/async.rs128
-rw-r--r--tests/run-make/coverage/async2.rs69
-rw-r--r--tests/run-make/coverage/closure.rs215
-rw-r--r--tests/run-make/coverage/closure_macro.rs40
-rw-r--r--tests/run-make/coverage/closure_macro_async.rs81
-rw-r--r--tests/run-make/coverage/compiletest-ignore-dir3
-rw-r--r--tests/run-make/coverage/conditions.rs87
-rw-r--r--tests/run-make/coverage/continue.rs69
-rw-r--r--tests/run-make/coverage/coverage_tools.mk6
-rw-r--r--tests/run-make/coverage/dead_code.rs37
-rw-r--r--tests/run-make/coverage/doctest.rs99
-rw-r--r--tests/run-make/coverage/drop_trait.rs33
-rw-r--r--tests/run-make/coverage/generator.rs30
-rw-r--r--tests/run-make/coverage/generics.rs48
-rw-r--r--tests/run-make/coverage/if.rs28
-rw-r--r--tests/run-make/coverage/if_else.rs40
-rw-r--r--tests/run-make/coverage/inline-dead.rs27
-rw-r--r--tests/run-make/coverage/inline.rs51
-rw-r--r--tests/run-make/coverage/inner_items.rs57
-rw-r--r--tests/run-make/coverage/issue-83601.rs14
-rw-r--r--tests/run-make/coverage/issue-84561.rs182
-rw-r--r--tests/run-make/coverage/issue-85461.rs10
-rw-r--r--tests/run-make/coverage/issue-93054.rs28
-rw-r--r--tests/run-make/coverage/lazy_boolean.rs61
-rw-r--r--tests/run-make/coverage/lib/doctest_crate.rs9
-rw-r--r--tests/run-make/coverage/lib/inline_always_with_dead_code.rs22
-rw-r--r--tests/run-make/coverage/lib/unused_mod_helper.rs3
-rw-r--r--tests/run-make/coverage/lib/used_crate.rs100
-rw-r--r--tests/run-make/coverage/lib/used_inline_crate.rs90
-rw-r--r--tests/run-make/coverage/loop_break_value.rs13
-rw-r--r--tests/run-make/coverage/loops_branches.rs61
-rw-r--r--tests/run-make/coverage/match_or_pattern.rs45
-rw-r--r--tests/run-make/coverage/nested_loops.rs25
-rw-r--r--tests/run-make/coverage/no_cov_crate.rs86
-rw-r--r--tests/run-make/coverage/overflow.rs63
-rw-r--r--tests/run-make/coverage/panic_unwind.rs31
-rw-r--r--tests/run-make/coverage/partial_eq.rs46
-rw-r--r--tests/run-make/coverage/simple_loop.rs35
-rw-r--r--tests/run-make/coverage/simple_match.rs43
-rw-r--r--tests/run-make/coverage/sort_groups.rs23
-rw-r--r--tests/run-make/coverage/test_harness.rs10
-rw-r--r--tests/run-make/coverage/tight_inf_loop.rs5
-rw-r--r--tests/run-make/coverage/try_error_result.rs118
-rw-r--r--tests/run-make/coverage/unused.rs39
-rw-r--r--tests/run-make/coverage/unused_mod.rs6
-rw-r--r--tests/run-make/coverage/uses_crate.rs15
-rw-r--r--tests/run-make/coverage/uses_inline_crate.rs20
-rw-r--r--tests/run-make/coverage/while.rs5
-rw-r--r--tests/run-make/coverage/while_early_ret.rs42
-rw-r--r--tests/run-make/coverage/yield.rs37
-rw-r--r--tests/run-make/crate-hash-rustc-version/Makefile2
-rw-r--r--tests/run-make/doctests-keep-binaries/Makefile13
-rw-r--r--tests/run-make/doctests-runtool/Makefile20
-rw-r--r--tests/run-make/doctests-runtool/runtool.rs3
-rw-r--r--tests/run-make/doctests-runtool/t.rs11
-rw-r--r--tests/run-make/dump-ice-to-disk/Makefile10
-rw-r--r--tests/run-make/dump-ice-to-disk/check.sh64
-rw-r--r--tests/run-make/dump-ice-to-disk/src/lib.rs7
-rw-r--r--tests/run-make/emit-path-unhashed/Makefile8
-rw-r--r--tests/run-make/emit-stack-sizes/foo.rs1
-rw-r--r--tests/run-make/emit-to-stdout/Makefile51
-rw-r--r--tests/run-make/emit-to-stdout/emit-link.stderr4
-rw-r--r--tests/run-make/emit-to-stdout/emit-llvm-bc.stderr4
-rw-r--r--tests/run-make/emit-to-stdout/emit-metadata.stderr4
-rw-r--r--tests/run-make/emit-to-stdout/emit-multiple-types.stderr4
-rw-r--r--tests/run-make/emit-to-stdout/emit-obj.stderr4
-rw-r--r--tests/run-make/emit-to-stdout/test.rs1
-rw-r--r--tests/run-make/exit-code/Makefile2
-rw-r--r--tests/run-make/extern-flag-pathless/Makefile27
-rw-r--r--tests/run-make/extern-flag-pathless/bar-dynamic.rs3
-rw-r--r--tests/run-make/extern-flag-pathless/bar-static.rs3
-rw-r--r--tests/run-make/extern-flag-pathless/bar.rs1
-rw-r--r--tests/run-make/extern-fn-explicit-align/Makefile6
-rw-r--r--tests/run-make/extern-fn-explicit-align/test.c93
-rw-r--r--tests/run-make/extern-fn-explicit-align/test.rs89
-rw-r--r--tests/run-make/extern-fn-struct-passing-abi/test.c36
-rw-r--r--tests/run-make/extern-fn-struct-passing-abi/test.rs21
-rw-r--r--tests/run-make/incr-foreign-head-span/Makefile2
-rw-r--r--tests/run-make/intrinsic-unreachable/exit-ret.rs1
-rw-r--r--tests/run-make/intrinsic-unreachable/exit-unreachable.rs1
-rw-r--r--tests/run-make/issue-71519/Makefile8
-rw-r--r--tests/run-make/issue-71519/main.rs4
-rw-r--r--tests/run-make/issue-88756-default-output/output-default.stdout7
-rw-r--r--tests/run-make/issue-96498/Makefile8
-rw-r--r--tests/run-make/jobserver-error/Makefile12
-rw-r--r--tests/run-make/jobserver-error/cannot_open_fd.stderr6
-rw-r--r--tests/run-make/jobserver-error/not_a_pipe.stderr4
-rw-r--r--tests/run-make/jobserver-error/poisoned_pipe.stderr (renamed from tests/run-make/jobserver-error/jobserver.stderr)2
-rw-r--r--tests/run-make/libtest-json/output-default.json2
-rw-r--r--tests/run-make/libtest-json/output-stdout-success.json4
-rw-r--r--tests/run-make/libtest-junit/output-default.xml2
-rw-r--r--tests/run-make/libtest-junit/output-stdout-success.xml2
-rwxr-xr-xtests/run-make/libtest-junit/validate_junit.py2
-rw-r--r--tests/run-make/llvm-ident/Makefile19
-rw-r--r--tests/run-make/ls-metadata/Makefile4
-rw-r--r--tests/run-make/lto-linkage-used-attr/Makefile9
-rw-r--r--tests/run-make/lto-linkage-used-attr/lib.rs50
-rw-r--r--tests/run-make/lto-linkage-used-attr/main.rs10
-rw-r--r--tests/run-make/macos-deployment-target/Makefile4
-rw-r--r--tests/run-make/metadata-dep-info/Makefile7
-rw-r--r--tests/run-make/metadata-dep-info/dash-separated.rs4
-rw-r--r--tests/run-make/metadata-dep-info/dash-separated_something-extra.normalized.d5
-rw-r--r--tests/run-make/mixing-libs/Makefile8
-rw-r--r--tests/run-make/no-builtins-attribute/Makefile9
-rw-r--r--tests/run-make/no-builtins-attribute/filecheck.main.txt5
-rw-r--r--tests/run-make/no-builtins-attribute/main.rs10
-rw-r--r--tests/run-make/no-builtins-attribute/no_builtins.rs5
-rw-r--r--tests/run-make/no-cdylib-as-rdylib/Makefile16
-rw-r--r--tests/run-make/no-cdylib-as-rdylib/bar.rs1
-rw-r--r--tests/run-make/no-cdylib-as-rdylib/foo.rs5
-rw-r--r--tests/run-make/optimization-remarks-dir-pgo/Makefile21
-rw-r--r--tests/run-make/optimization-remarks-dir-pgo/foo.rs6
-rw-r--r--tests/run-make/optimization-remarks-dir/Makefile12
-rw-r--r--tests/run-make/optimization-remarks-dir/foo.rs6
-rw-r--r--tests/run-make/output-filename-overwrites-input/Makefile2
-rw-r--r--tests/run-make/overwrite-input/Makefile10
-rw-r--r--tests/run-make/overwrite-input/file.stderr2
-rw-r--r--tests/run-make/overwrite-input/folder.stderr2
-rw-r--r--tests/run-make/overwrite-input/main.stderr2
-rw-r--r--tests/run-make/panic-abort-eh_frame/Makefile10
-rw-r--r--tests/run-make/panic-abort-eh_frame/foo.rs34
-rw-r--r--tests/run-make/pass-linker-flags-flavor/Makefile11
-rw-r--r--tests/run-make/pass-linker-flags-flavor/attribute.rs12
-rw-r--r--tests/run-make/pass-linker-flags-flavor/empty.rs (renamed from tests/run-make/pass-linker-flags/rs.rs)0
-rw-r--r--tests/run-make/pass-linker-flags-from-dep/Makefile6
-rw-r--r--tests/run-make/pass-linker-flags-from-dep/rust_dep_attr.rs14
-rw-r--r--tests/run-make/pass-linker-flags-from-dep/rust_dep_flag.rs (renamed from tests/run-make/pass-linker-flags-from-dep/rust_dep.rs)0
-rw-r--r--tests/run-make/pass-linker-flags/Makefile3
-rw-r--r--tests/run-make/pass-linker-flags/attribute.rs11
-rw-r--r--tests/run-make/pass-linker-flags/empty.rs1
-rw-r--r--tests/run-make/pdb-buildinfo-cl-cmd/Makefile16
-rw-r--r--tests/run-make/pdb-buildinfo-cl-cmd/main.rs2
-rw-r--r--tests/run-make/pdb-buildinfo-cl-cmd/stringlist.txt1
-rw-r--r--tests/run-make/pgo-branch-weights/Makefile1
-rw-r--r--tests/run-make/pgo-gen-lto/Makefile1
-rw-r--r--tests/run-make/pgo-gen/Makefile1
-rw-r--r--tests/run-make/pgo-indirect-call-promotion/Makefile1
-rw-r--r--tests/run-make/pgo-indirect-call-promotion/filecheck-patterns.txt4
-rw-r--r--tests/run-make/pgo-use/Makefile1
-rw-r--r--tests/run-make/pointer-auth-link-with-c/Makefile1
-rw-r--r--tests/run-make/pretty-print-with-dep-file/Makefile9
-rw-r--r--tests/run-make/pretty-print-with-dep-file/with-dep.rs1
-rw-r--r--tests/run-make/print-cfg/Makefile19
-rw-r--r--tests/run-make/print-native-static-libs/Makefile6
-rw-r--r--tests/run-make/print-native-static-libs/bar.rs6
-rw-r--r--tests/run-make/profile/Makefile1
-rw-r--r--tests/run-make/raw-dylib-alt-calling-convention/Makefile12
-rw-r--r--tests/run-make/raw-dylib-import-name-type/Makefile7
-rw-r--r--tests/run-make/raw-dylib-inline-cross-dylib/Makefile7
-rw-r--r--tests/run-make/raw-dylib-link-ordinal/Makefile7
-rw-r--r--tests/run-make/raw-dylib-stdcall-ordinal/Makefile7
-rw-r--r--tests/run-make/remap-path-prefix-dwarf/Makefile37
-rw-r--r--tests/run-make/remap-path-prefix/Makefile32
-rw-r--r--tests/run-make/rlib-format-packed-bundled-libs-3/Makefile4
-rw-r--r--tests/run-make/rlib-format-packed-bundled-libs-3/rust_dep.rs2
-rw-r--r--tests/run-make/rmeta-preferred/Makefile16
-rw-r--r--tests/run-make/rmeta-preferred/lib.rs14
-rw-r--r--tests/run-make/rmeta-preferred/rmeta_aux.rs3
-rw-r--r--tests/run-make/rust-lld-custom-target/Makefile7
-rw-r--r--tests/run-make/rust-lld-custom-target/custom-target.json57
-rw-r--r--tests/run-make/rust-lld-custom-target/lib.rs9
-rw-r--r--tests/run-make/rust-lld/Makefile8
-rw-r--r--tests/run-make/rust-lld/main.rs4
-rw-r--r--tests/run-make/rustc-macro-dep-files/foo.rs2
-rwxr-xr-xtests/run-make/rustdoc-map-file/validate_json.py2
-rw-r--r--tests/run-make/rustdoc-themes/Makefile3
-rw-r--r--tests/run-make/rustdoc-themes/foo.rs2
-rw-r--r--tests/run-make/short-ice/Makefile1
-rw-r--r--tests/run-make/short-ice/check.sh6
-rw-r--r--tests/run-make/silly-file-names/Makefile12
-rw-r--r--tests/run-make/silly-file-names/silly-file-names.rs4
-rw-r--r--tests/run-make/silly-file-names/silly-file-names.run.stdout2
-rw-r--r--tests/run-make/split-debuginfo/Makefile64
-rw-r--r--tests/run-make/sysroot-crates-are-unstable/test.py2
-rw-r--r--tests/run-make/target-specs/Makefile1
-rw-r--r--tests/run-make/target-specs/endianness-mismatch.json11
-rw-r--r--tests/run-make/tools.mk24
-rw-r--r--tests/run-make/unknown-mod-stdin/Makefile8
-rw-r--r--tests/run-make/unknown-mod-stdin/unknown-mod.stderr12
-rw-r--r--tests/run-make/unknown-mod-stdin/unknown-mod.stdout0
-rw-r--r--tests/run-make/use-extern-for-plugins/Makefile17
-rw-r--r--tests/run-make/use-extern-for-plugins/bar.rs9
-rw-r--r--tests/run-make/use-extern-for-plugins/baz.rs8
-rw-r--r--tests/run-make/use-extern-for-plugins/foo.rs8
-rw-r--r--tests/run-make/valid-print-requests/valid-print-requests.stderr2
-rw-r--r--tests/run-make/wasm-exceptions-nostd/Makefile12
-rw-r--r--tests/run-make/wasm-exceptions-nostd/src/arena_alloc.rs67
-rw-r--r--tests/run-make/wasm-exceptions-nostd/src/lib.rs60
-rw-r--r--tests/run-make/wasm-exceptions-nostd/src/logging.rs9
-rw-r--r--tests/run-make/wasm-exceptions-nostd/src/panicking.rs29
-rw-r--r--tests/run-make/wasm-exceptions-nostd/verify.mjs75
-rw-r--r--tests/run-make/wasm-override-linker/Makefile13
-rw-r--r--tests/run-make/wasm-override-linker/foo.rs6
-rw-r--r--tests/run-make/windows-safeseh/Makefile19
-rw-r--r--tests/run-make/windows-safeseh/bar.rs1
-rw-r--r--tests/run-make/windows-safeseh/baz.rs4
-rw-r--r--tests/run-make/windows-safeseh/foo.rs (renamed from tests/run-make/issue-96498/foo.rs)0
-rw-r--r--tests/run-make/x86_64-fortanix-unknown-sgx-lvi/print.checks8
-rw-r--r--tests/run-make/x86_64-fortanix-unknown-sgx-lvi/script.sh9
257 files changed, 1586 insertions, 5803 deletions
diff --git a/tests/run-make/comment-section/Makefile b/tests/run-make/comment-section/Makefile
new file mode 100644
index 000000000..9f810063c
--- /dev/null
+++ b/tests/run-make/comment-section/Makefile
@@ -0,0 +1,15 @@
+include ../tools.mk
+
+# only-linux
+
+all:
+ echo 'fn main(){}' | $(RUSTC) - --emit=link,obj -Csave-temps --target=$(TARGET)
+
+ # Check linked output has a `.comment` section with the expected content.
+ readelf -p '.comment' $(TMPDIR)/rust_out | $(CGREP) -F 'rustc version 1.'
+
+ # Check all object files (including temporary outputs) have a `.comment`
+ # section with the expected content.
+ set -e; for f in $(TMPDIR)/*.o; do \
+ readelf -p '.comment' $$f | $(CGREP) -F 'rustc version 1.'; \
+ done
diff --git a/tests/run-make/compressed-debuginfo/Makefile b/tests/run-make/compressed-debuginfo/Makefile
new file mode 100644
index 000000000..d2f24dde0
--- /dev/null
+++ b/tests/run-make/compressed-debuginfo/Makefile
@@ -0,0 +1,14 @@
+# ignore-cross-compile
+include ../tools.mk
+
+# only-linux
+#
+# This tests debuginfo-compression.
+
+all: zlib zstandard
+
+zlib:
+ test "`$(RUSTC) --crate-name=foo --crate-type=lib --emit=obj -C debuginfo=full -Z debuginfo-compression=zlib foo.rs 2>&1 | sed 's/.*unknown.*zlib.*/missing/' | head -n 1`" = missing || readelf -t $(TMPDIR)/foo.o | grep -q ZLIB
+
+zstandard:
+ test "`$(RUSTC) --crate-name=foo --crate-type=lib --emit=obj -C debuginfo=full -Z debuginfo-compression=zstd foo.rs 2>&1 | sed 's/.*unknown.*zstd.*/missing/' | head -n 1`" = missing || readelf -t $(TMPDIR)/foo.o | grep -q ZST
diff --git a/tests/run-make/compressed-debuginfo/foo.rs b/tests/run-make/compressed-debuginfo/foo.rs
new file mode 100644
index 000000000..185ce2245
--- /dev/null
+++ b/tests/run-make/compressed-debuginfo/foo.rs
@@ -0,0 +1,3 @@
+pub fn foo() -> i32 {
+ 42
+}
diff --git a/tests/run-make/const_fn_mir/Makefile b/tests/run-make/const_fn_mir/Makefile
index 6d72c1227..339944613 100644
--- a/tests/run-make/const_fn_mir/Makefile
+++ b/tests/run-make/const_fn_mir/Makefile
@@ -3,9 +3,4 @@ include ../tools.mk
all:
$(RUSTC) main.rs --emit=mir -o "$(TMPDIR)"/dump.mir
-
-ifdef RUSTC_BLESS_TEST
- cp "$(TMPDIR)"/dump.mir dump.mir
-else
- $(DIFF) dump.mir "$(TMPDIR)"/dump.mir
-endif
+ $(RUSTC_TEST_OP) "$(TMPDIR)"/dump.mir dump.mir
diff --git a/tests/run-make/const_fn_mir/dump.mir b/tests/run-make/const_fn_mir/dump.mir
index 9cc70d3b0..ced170bbe 100644
--- a/tests/run-make/const_fn_mir/dump.mir
+++ b/tests/run-make/const_fn_mir/dump.mir
@@ -1,48 +1,45 @@
// WARNING: This output format is intended for human consumers only
// and is subject to change without notice. Knock yourself out.
fn foo() -> i32 {
- let mut _0: i32; // return place in scope 0 at main.rs:4:19: 4:22
- let mut _1: (i32, bool); // in scope 0 at main.rs:5:5: 5:10
+ let mut _0: i32;
+ let mut _1: (i32, bool);
bb0: {
- _1 = CheckedAdd(const 5_i32, const 6_i32); // scope 0 at main.rs:5:5: 5:10
- assert(!move (_1.1: bool), "attempt to compute `{} + {}`, which would overflow", const 5_i32, const 6_i32) -> bb1; // scope 0 at main.rs:5:5: 5:10
+ _1 = CheckedAdd(const 5_i32, const 6_i32);
+ assert(!move (_1.1: bool), "attempt to compute `{} + {}`, which would overflow", const 5_i32, const 6_i32) -> [success: bb1, unwind continue];
}
bb1: {
- _0 = move (_1.0: i32); // scope 0 at main.rs:5:5: 5:10
- return; // scope 0 at main.rs:6:2: 6:2
+ _0 = move (_1.0: i32);
+ return;
}
}
// MIR FOR CTFE
fn foo() -> i32 {
- let mut _0: i32; // return place in scope 0 at main.rs:4:19: 4:22
- let mut _1: (i32, bool); // in scope 0 at main.rs:5:5: 5:10
+ let mut _0: i32;
+ let mut _1: (i32, bool);
bb0: {
- _1 = CheckedAdd(const 5_i32, const 6_i32); // scope 0 at main.rs:5:5: 5:10
- assert(!move (_1.1: bool), "attempt to compute `{} + {}`, which would overflow", const 5_i32, const 6_i32) -> bb1; // scope 0 at main.rs:5:5: 5:10
+ _1 = CheckedAdd(const 5_i32, const 6_i32);
+ assert(!move (_1.1: bool), "attempt to compute `{} + {}`, which would overflow", const 5_i32, const 6_i32) -> [success: bb1, unwind continue];
}
bb1: {
- _0 = move (_1.0: i32); // scope 0 at main.rs:5:5: 5:10
- return; // scope 0 at main.rs:6:2: 6:2
+ _0 = move (_1.0: i32);
+ return;
}
}
fn main() -> () {
- let mut _0: (); // return place in scope 0 at main.rs:8:11: 8:11
- let _1: i32; // in scope 0 at main.rs:9:5: 9:10
+ let mut _0: ();
+ let _1: i32;
bb0: {
- _1 = foo() -> bb1; // scope 0 at main.rs:9:5: 9:10
- // mir::Constant
- // + span: main.rs:9:5: 9:8
- // + literal: Const { ty: fn() -> i32 {foo}, val: Value(<ZST>) }
+ _1 = foo() -> [return: bb1, unwind continue];
}
bb1: {
- return; // scope 0 at main.rs:10:2: 10:2
+ return;
}
}
diff --git a/tests/run-make/coverage-llvmir/Makefile b/tests/run-make/coverage-llvmir/Makefile
index 7be655053..be92f8ac8 100644
--- a/tests/run-make/coverage-llvmir/Makefile
+++ b/tests/run-make/coverage-llvmir/Makefile
@@ -6,7 +6,7 @@
# version during testing, with an additional directive at the top of this file
# that sets, for example: `min-llvm-version: 12.0`
-include ../coverage/coverage_tools.mk
+include ../tools.mk
BASEDIR=../coverage-llvmir
diff --git a/tests/run-make/coverage-llvmir/filecheck.testprog.txt b/tests/run-make/coverage-llvmir/filecheck.testprog.txt
index b3a8808df..8ab18da21 100644
--- a/tests/run-make/coverage-llvmir/filecheck.testprog.txt
+++ b/tests/run-make/coverage-llvmir/filecheck.testprog.txt
@@ -3,12 +3,12 @@
WINDOWS: $__llvm_profile_runtime_user = comdat any
-CHECK: @__covrec_{{[A-F0-9]+}}u = linkonce_odr hidden constant
-CHECK-SAME: section "[[INSTR_PROF_COVFUN]]"[[COMDAT_IF_SUPPORTED]], align 8
-
CHECK: @__llvm_coverage_mapping = private constant
CHECK-SAME: section "[[INSTR_PROF_COVMAP]]", align 8
+CHECK: @__covrec_{{[A-F0-9]+}}u = linkonce_odr hidden constant
+CHECK-SAME: section "[[INSTR_PROF_COVFUN]]"[[COMDAT_IF_SUPPORTED]], align 8
+
WINDOWS: @__llvm_profile_runtime = external{{.*}}global i32
CHECK: @__profc__R{{[a-zA-Z0-9_]+}}testprog14will_be_called = {{private|internal}} global
@@ -39,10 +39,10 @@ CHECK-NOT: [[DEFINE_INTERNAL]]
CHECK: atomicrmw add ptr
CHECK-SAME: @__profc__R{{[a-zA-Z0-9_]+}}testprog14will_be_called,
-CHECK: declare void @llvm.instrprof.increment({{i8\*|ptr}}, i64, i32, i32) #[[LLVM_INSTRPROF_INCREMENT_ATTR:[0-9]+]]
+CHECK: declare void @llvm.instrprof.increment(ptr, i64, i32, i32) #[[LLVM_INSTRPROF_INCREMENT_ATTR:[0-9]+]]
WINDOWS: define linkonce_odr hidden i32 @__llvm_profile_runtime_user() #[[LLVM_PROFILE_RUNTIME_USER_ATTR:[0-9]+]] comdat {
-WINDOWS-NEXT: %1 = load i32, {{i32\*|ptr}} @__llvm_profile_runtime
+WINDOWS-NEXT: %1 = load i32, ptr @__llvm_profile_runtime
WINDOWS-NEXT: ret i32 %1
WINDOWS-NEXT: }
diff --git a/tests/run-make/coverage-reports/Makefile b/tests/run-make/coverage-reports/Makefile
deleted file mode 100644
index 0ae409c41..000000000
--- a/tests/run-make/coverage-reports/Makefile
+++ /dev/null
@@ -1,178 +0,0 @@
-# needs-profiler-support
-# ignore-windows-gnu
-
-# FIXME(pietroalbini): this test currently does not work on cross-compiled
-# targets because remote-test is not capable of sending back the *.profraw
-# files generated by the LLVM instrumentation.
-# ignore-cross-compile
-
-# Rust coverage maps support LLVM Coverage Mapping Format versions 5 and 6,
-# corresponding with LLVM versions 12 and 13, respectively.
-# When upgrading LLVM versions, consider whether to enforce a minimum LLVM
-# version during testing, with an additional directive at the top of this file
-# that sets, for example: `min-llvm-version: 12.0`
-
-# FIXME(mati865): MinGW GCC miscompiles compiler-rt profiling library but with Clang it works
-# properly. Since we only have GCC on the CI ignore the test for now.
-
-include ../coverage/coverage_tools.mk
-
-BASEDIR=../coverage-reports
-SOURCEDIR=../coverage
-
-# The `llvm-cov show` flag `--debug`, used to generate the `counters` output files, is only
-# enabled if LLVM assertions are enabled. This requires Rust config `llvm/optimize` and not
-# `llvm/release_debuginfo`. Note that some CI builds disable debug assertions (by setting
-# `NO_LLVM_ASSERTIONS=1`), so the tests must still pass even if the `--debug` flag is
-# not supported. (Note that `counters` files are only produced in the `$(TMPDIR)`
-# directory, for inspection and debugging support. They are *not* copied to `expected_*`
-# files when `--bless`ed.)
-LLVM_COV_DEBUG := $(shell \
- "$(LLVM_BIN_DIR)"/llvm-cov show --debug 2>&1 | \
- grep -q "Unknown command line argument '--debug'"; \
- echo $$?)
-ifeq ($(LLVM_COV_DEBUG), 1)
-DEBUG_FLAG=--debug
-endif
-
-# FIXME(richkadel): I'm adding `--ignore-filename-regex=` line(s) for specific test(s) that produce
-# `llvm-cov` results for multiple files (for example `uses_crate.rs` and `used_crate/mod.rs`) as a
-# workaround for two problems causing tests to fail on Windows:
-#
-# 1. When multiple files appear in the `llvm-cov show` results, each file's coverage results can
-# appear in different a different order. Whether this is random or, somehow, platform-specific,
-# the Windows output flips the order of the files, compared to Linux. In the `uses_crate.rs`
-# test, the only test-unique (interesting) results we care about are the results for only one
-# of the two files, `mod/uses_crate.rs`, so the workaround is to ignore all but this one file.
-# In the future, we may want a more sophisticated solution that splits apart `llvm-cov show`
-# results into separate results files for each result (taking care not to create new file
-# paths that might be too long for Windows MAX_PATH limits when creating these new sub-results,
-# as well).
-# 2. When multiple files appear in the `llvm-cov show` results, the results for each file are
-# prefixed with their filename, including platform-specific path separators (`\` for Windows,
-# and `/` everywhere else). This could be filtered or normalized of course, but by ignoring
-# coverage results for all but one of the file, the filenames are no longer included anyway.
-# If this changes (if/when we decide to support `llvm-cov show` results for multiple files),
-# the file path separator differences may need to be addressed.
-#
-# Since this is only a workaround, I decided to implement the override by adding an option for
-# each file to be ignored, using a `--ignore-filename-regex=` entry for each one, rather than
-# implement some more sophisticated solution with a new custom test directive in the test file
-# itself (similar to `expect-exit-status`) because that would add a lot of complexity and still
-# be a workaround, with the same result, with no benefit.
-#
-# Yes these `--ignore-filename-regex=` options are included in all invocations of `llvm-cov show`
-# for now, but it is effectively ignored for all tests that don't include this file anyway.
-#
-# (Note that it's also possible the `_counters.<test>.txt` and `<test>.json` files (if generated)
-# may order results from multiple files inconsistently, which might also have to be accommodated
-# if and when we allow `llvm-cov` to produce results for multiple files. Note, the path separators
-# appear to be normalized to `/` in those files, thankfully.)
-LLVM_COV_IGNORE_FILES=\
- --ignore-filename-regex='(uses_crate.rs|uses_inline_crate.rs|unused_mod.rs)'
-
-all: $(patsubst $(SOURCEDIR)/lib/%.rs,%,$(wildcard $(SOURCEDIR)/lib/*.rs)) $(patsubst $(SOURCEDIR)/%.rs,%,$(wildcard $(SOURCEDIR)/*.rs))
-
-# Ensure there are no `expected` results for tests that may have been removed or renamed
-.PHONY: clear_expected_if_blessed
-clear_expected_if_blessed:
-ifdef RUSTC_BLESS_TEST
- rm -f expected_*
-endif
-
--include clear_expected_if_blessed
-
-%: $(SOURCEDIR)/lib/%.rs
- # Compile the test library with coverage instrumentation
- $(RUSTC) $(SOURCEDIR)/lib/$@.rs \
- $$( sed -n 's/^\/\/ compile-flags: \([^#]*\).*/\1/p' $(SOURCEDIR)/lib/$@.rs ) \
- --crate-type rlib -Cinstrument-coverage --target $(TARGET)
-
-%: $(SOURCEDIR)/%.rs
- # Compile the test program with coverage instrumentation
- $(RUSTC) $(SOURCEDIR)/$@.rs \
- $$( sed -n 's/^\/\/ compile-flags: \([^#]*\).*/\1/p' $(SOURCEDIR)/$@.rs ) \
- -L "$(TMPDIR)" -Cinstrument-coverage --target $(TARGET)
-
- # Run it in order to generate some profiling data,
- # with `LLVM_PROFILE_FILE=<profdata_file>` environment variable set to
- # output the coverage stats for this run.
- LLVM_PROFILE_FILE="$(TMPDIR)"/$@.profraw \
- $(call RUN,$@) || \
- ( \
- status=$$?; \
- grep -q "^\/\/ expect-exit-status-$$status" $(SOURCEDIR)/$@.rs || \
- ( >&2 echo "program exited with an unexpected exit status: $$status"; \
- false \
- ) \
- )
-
- # Run it through rustdoc as well to cover doctests.
- # `%p` is the pid, and `%m` the binary signature. We suspect that the pid alone
- # might result in overwritten files and failed tests, as rustdoc spawns each
- # doctest as its own process, so make sure the filename is as unique as possible.
- LLVM_PROFILE_FILE="$(TMPDIR)"/$@-%p-%m.profraw \
- $(RUSTDOC) --crate-name workaround_for_79771 --test $(SOURCEDIR)/$@.rs \
- $$( sed -n 's/^\/\/ compile-flags: \([^#]*\).*/\1/p' $(SOURCEDIR)/$@.rs ) \
- -L "$(TMPDIR)" -Cinstrument-coverage \
- -Z unstable-options --persist-doctests=$(TMPDIR)/rustdoc-$@
-
- # Postprocess the profiling data so it can be used by the llvm-cov tool
- "$(LLVM_BIN_DIR)"/llvm-profdata merge --sparse \
- "$(TMPDIR)"/$@*.profraw \
- -o "$(TMPDIR)"/$@.profdata
-
- # Generate a coverage report using `llvm-cov show`.
- "$(LLVM_BIN_DIR)"/llvm-cov show \
- $(DEBUG_FLAG) \
- $(LLVM_COV_IGNORE_FILES) \
- --compilation-dir=. \
- --Xdemangler="$(RUST_DEMANGLER)" \
- --show-line-counts-or-regions \
- --instr-profile="$(TMPDIR)"/$@.profdata \
- $(call BIN,"$(TMPDIR)"/$@) \
- $$( \
- for file in $(TMPDIR)/rustdoc-$@/*/rust_out*; do \
- [ -x "$$file" ] && printf "%s %s " -object $$file; \
- done \
- ) \
- 2> "$(TMPDIR)"/show_coverage_stderr.$@.txt \
- | "$(PYTHON)" $(BASEDIR)/normalize_paths.py \
- | "$(PYTHON)" $(BASEDIR)/sort_subviews.py \
- > "$(TMPDIR)"/actual_show_coverage.$@.txt || \
- ( status=$$? ; \
- >&2 cat "$(TMPDIR)"/show_coverage_stderr.$@.txt ; \
- exit $$status \
- )
-
-ifdef DEBUG_FLAG
- # The first line (beginning with "Args:" contains hard-coded, build-specific
- # file paths. Strip that line and keep the remaining lines with counter debug
- # data.
- tail -n +2 "$(TMPDIR)"/show_coverage_stderr.$@.txt \
- > "$(TMPDIR)"/actual_show_coverage_counters.$@.txt
-endif
-
-ifdef RUSTC_BLESS_TEST
- cp "$(TMPDIR)"/actual_show_coverage.$@.txt \
- expected_show_coverage.$@.txt
-else
- # Compare the show coverage output (`--bless` refreshes `typical` files).
- #
- # `llvm-cov show` normally prints instantiation groups in an unpredictable
- # order, but we have used `sort_subviews.py` to sort them, so we can still
- # check the output directly with `diff`.
- #
- # Some of the test cases are currently not working (since #110393) and have
- # been marked with `// ignore-llvm-cov-show-diffs` so that they don't fail
- # the build.
-
- $(DIFF) \
- expected_show_coverage.$@.txt "$(TMPDIR)"/actual_show_coverage.$@.txt || \
- ( grep -q '^\/\/ ignore-llvm-cov-show-diffs' $(SOURCEDIR)/$@.rs && \
- >&2 echo 'diff failed, but suppressed with `// ignore-llvm-cov-show-diffs` in $(SOURCEDIR)/$@.rs' \
- ) || \
- ( >&2 echo 'diff failed, and not suppressed without `// ignore-llvm-cov-show-diffs` in $(SOURCEDIR)/$@.rs'; \
- false \
- )
-endif
diff --git a/tests/run-make/coverage-reports/expected_show_coverage.abort.txt b/tests/run-make/coverage-reports/expected_show_coverage.abort.txt
deleted file mode 100644
index a71c58d61..000000000
--- a/tests/run-make/coverage-reports/expected_show_coverage.abort.txt
+++ /dev/null
@@ -1,69 +0,0 @@
- 1| |#![feature(c_unwind)]
- 2| |#![allow(unused_assignments)]
- 3| |
- 4| 12|extern "C" fn might_abort(should_abort: bool) {
- 5| 12| if should_abort {
- 6| 0| println!("aborting...");
- 7| 0| panic!("panics and aborts");
- 8| 12| } else {
- 9| 12| println!("Don't Panic");
- 10| 12| }
- 11| 12|}
- 12| |
- 13| 1|fn main() -> Result<(), u8> {
- 14| 1| let mut countdown = 10;
- 15| 11| while countdown > 0 {
- 16| 10| if countdown < 5 {
- 17| 4| might_abort(false);
- 18| 6| }
- 19| | // See discussion (below the `Notes` section) on coverage results for the closing brace.
- 20| 10| if countdown < 5 { might_abort(false); } // Counts for different regions on one line.
- ^4 ^6
- 21| | // For the following example, the closing brace is the last character on the line.
- 22| | // This shows the character after the closing brace is highlighted, even if that next
- 23| | // character is a newline.
- 24| 10| if countdown < 5 { might_abort(false); }
- ^4 ^6
- 25| 10| countdown -= 1;
- 26| | }
- 27| 1| Ok(())
- 28| 1|}
- 29| |
- 30| |// Notes:
- 31| |// 1. Compare this program and its coverage results to those of the similar tests
- 32| |// `panic_unwind.rs` and `try_error_result.rs`.
- 33| |// 2. This test confirms the coverage generated when a program includes `UnwindAction::Terminate`.
- 34| |// 3. The test does not invoke the abort. By executing to a successful completion, the coverage
- 35| |// results show where the program did and did not execute.
- 36| |// 4. If the program actually aborted, the coverage counters would not be saved (which "works as
- 37| |// intended"). Coverage results would show no executed coverage regions.
- 38| |// 6. If `should_abort` is `true` and the program aborts, the program exits with a `132` status
- 39| |// (on Linux at least).
- 40| |
- 41| |/*
- 42| |
- 43| |Expect the following coverage results:
- 44| |
- 45| |```text
- 46| | 16| 11| while countdown > 0 {
- 47| | 17| 10| if countdown < 5 {
- 48| | 18| 4| might_abort(false);
- 49| | 19| 6| }
- 50| |```
- 51| |
- 52| |This is actually correct.
- 53| |
- 54| |The condition `countdown < 5` executed 10 times (10 loop iterations).
- 55| |
- 56| |It evaluated to `true` 4 times, and executed the `might_abort()` call.
- 57| |
- 58| |It skipped the body of the `might_abort()` call 6 times. If an `if` does not include an explicit
- 59| |`else`, the coverage implementation injects a counter, at the character immediately after the `if`s
- 60| |closing brace, to count the "implicit" `else`. This is the only way to capture the coverage of the
- 61| |non-true condition.
- 62| |
- 63| |As another example of why this is important, say the condition was `countdown < 50`, which is always
- 64| |`true`. In that case, we wouldn't have a test for what happens if `might_abort()` is not called.
- 65| |The closing brace would have a count of `0`, highlighting the missed coverage.
- 66| |*/
-
diff --git a/tests/run-make/coverage-reports/expected_show_coverage.assert.txt b/tests/run-make/coverage-reports/expected_show_coverage.assert.txt
deleted file mode 100644
index 405688806..000000000
--- a/tests/run-make/coverage-reports/expected_show_coverage.assert.txt
+++ /dev/null
@@ -1,34 +0,0 @@
- 1| |#![allow(unused_assignments)]
- 2| |// expect-exit-status-101
- 3| |
- 4| 4|fn might_fail_assert(one_plus_one: u32) {
- 5| 4| println!("does 1 + 1 = {}?", one_plus_one);
- 6| 4| assert_eq!(1 + 1, one_plus_one, "the argument was wrong");
- ^1
- 7| 3|}
- 8| |
- 9| 1|fn main() -> Result<(),u8> {
- 10| 1| let mut countdown = 10;
- 11| 11| while countdown > 0 {
- 12| 11| if countdown == 1 {
- 13| 1| might_fail_assert(3);
- 14| 10| } else if countdown < 5 {
- 15| 3| might_fail_assert(2);
- 16| 6| }
- 17| 10| countdown -= 1;
- 18| | }
- 19| 0| Ok(())
- 20| 0|}
- 21| |
- 22| |// Notes:
- 23| |// 1. Compare this program and its coverage results to those of the very similar test
- 24| |// `panic_unwind.rs`, and similar tests `abort.rs` and `try_error_result.rs`.
- 25| |// 2. This test confirms the coverage generated when a program passes or fails an `assert!()` or
- 26| |// related `assert_*!()` macro.
- 27| |// 3. Notably, the `assert` macros *do not* generate `TerminatorKind::Assert`. The macros produce
- 28| |// conditional expressions, `TerminatorKind::SwitchInt` branches, and a possible call to
- 29| |// `begin_panic_fmt()` (that begins a panic unwind, if the assertion test fails).
- 30| |// 4. `TerminatoKind::Assert` is, however, also present in the MIR generated for this test
- 31| |// (and in many other coverage tests). The `Assert` terminator is typically generated by the
- 32| |// Rust compiler to check for runtime failures, such as numeric overflows.
-
diff --git a/tests/run-make/coverage-reports/expected_show_coverage.async.txt b/tests/run-make/coverage-reports/expected_show_coverage.async.txt
deleted file mode 100644
index 93c1535b0..000000000
--- a/tests/run-make/coverage-reports/expected_show_coverage.async.txt
+++ /dev/null
@@ -1,139 +0,0 @@
- 1| |#![allow(unused_assignments, dead_code)]
- 2| |
- 3| |// compile-flags: --edition=2018 -C opt-level=1
- 4| |
- 5| 1|async fn c(x: u8) -> u8 {
- 6| 1| if x == 8 {
- 7| 1| 1
- 8| | } else {
- 9| 0| 0
- 10| | }
- 11| 1|}
- 12| |
- 13| 0|async fn d() -> u8 { 1 }
- 14| |
- 15| 0|async fn e() -> u8 { 1 } // unused function; executor does not block on `g()`
- 16| |
- 17| 1|async fn f() -> u8 { 1 }
- 18| |
- 19| 0|async fn foo() -> [bool; 10] { [false; 10] } // unused function; executor does not block on `h()`
- 20| |
- 21| 1|pub async fn g(x: u8) {
- 22| 0| match x {
- 23| 0| y if e().await == y => (),
- 24| 0| y if f().await == y => (),
- 25| 0| _ => (),
- 26| | }
- 27| 0|}
- 28| |
- 29| 1|async fn h(x: usize) { // The function signature is counted when called, but the body is not
- 30| 0| // executed (not awaited) so the open brace has a `0` count (at least when
- 31| 0| // displayed with `llvm-cov show` in color-mode).
- 32| 0| match x {
- 33| 0| y if foo().await[y] => (),
- 34| 0| _ => (),
- 35| | }
- 36| 0|}
- 37| |
- 38| 1|async fn i(x: u8) { // line coverage is 1, but there are 2 regions:
- 39| 1| // (a) the function signature, counted when the function is called; and
- 40| 1| // (b) the open brace for the function body, counted once when the body is
- 41| 1| // executed asynchronously.
- 42| 1| match x {
- 43| 1| y if c(x).await == y + 1 => { d().await; }
- ^0 ^0 ^0 ^0
- 44| 1| y if f().await == y + 1 => (),
- ^0 ^0 ^0
- 45| 1| _ => (),
- 46| | }
- 47| 1|}
- 48| |
- 49| 1|fn j(x: u8) {
- 50| 1| // non-async versions of `c()`, `d()`, and `f()` to make it similar to async `i()`.
- 51| 1| fn c(x: u8) -> u8 {
- 52| 1| if x == 8 {
- 53| 1| 1 // This line appears covered, but the 1-character expression span covering the `1`
- ^0
- 54| 1| // is not executed. (`llvm-cov show` displays a `^0` below the `1` ). This is because
- 55| 1| // `fn j()` executes the open brace for the function body, followed by the function's
- 56| 1| // first executable statement, `match x`. Inner function declarations are not
- 57| 1| // "visible" to the MIR for `j()`, so the code region counts all lines between the
- 58| 1| // open brace and the first statement as executed, which is, in a sense, true.
- 59| 1| // `llvm-cov show` overcomes this kind of situation by showing the actual counts
- 60| 1| // of the enclosed coverages, (that is, the `1` expression was not executed, and
- 61| 1| // accurately displays a `0`).
- 62| 1| } else {
- 63| 1| 0
- 64| 1| }
- 65| 1| }
- 66| 1| fn d() -> u8 { 1 } // inner function is defined in-line, but the function is not executed
- ^0
- 67| 1| fn f() -> u8 { 1 }
- 68| 1| match x {
- 69| 1| y if c(x) == y + 1 => { d(); }
- ^0 ^0
- 70| 1| y if f() == y + 1 => (),
- ^0 ^0
- 71| 1| _ => (),
- 72| | }
- 73| 1|}
- 74| |
- 75| 0|fn k(x: u8) { // unused function
- 76| 0| match x {
- 77| 0| 1 => (),
- 78| 0| 2 => (),
- 79| 0| _ => (),
- 80| | }
- 81| 0|}
- 82| |
- 83| 1|fn l(x: u8) {
- 84| 1| match x {
- 85| 0| 1 => (),
- 86| 0| 2 => (),
- 87| 1| _ => (),
- 88| | }
- 89| 1|}
- 90| |
- 91| 1|async fn m(x: u8) -> u8 { x - 1 }
- ^0
- 92| |
- 93| 1|fn main() {
- 94| 1| let _ = g(10);
- 95| 1| let _ = h(9);
- 96| 1| let mut future = Box::pin(i(8));
- 97| 1| j(7);
- 98| 1| l(6);
- 99| 1| let _ = m(5);
- 100| 1| executor::block_on(future.as_mut());
- 101| 1|}
- 102| |
- 103| |mod executor {
- 104| | use core::{
- 105| | future::Future,
- 106| | pin::Pin,
- 107| | task::{Context, Poll, RawWaker, RawWakerVTable, Waker},
- 108| | };
- 109| |
- 110| 1| pub fn block_on<F: Future>(mut future: F) -> F::Output {
- 111| 1| let mut future = unsafe { Pin::new_unchecked(&mut future) };
- 112| 1| use std::hint::unreachable_unchecked;
- 113| 1| static VTABLE: RawWakerVTable = RawWakerVTable::new(
- 114| 1| |_| unsafe { unreachable_unchecked() }, // clone
- ^0
- 115| 1| |_| unsafe { unreachable_unchecked() }, // wake
- ^0
- 116| 1| |_| unsafe { unreachable_unchecked() }, // wake_by_ref
- ^0
- 117| 1| |_| (),
- 118| 1| );
- 119| 1| let waker = unsafe { Waker::from_raw(RawWaker::new(core::ptr::null(), &VTABLE)) };
- 120| 1| let mut context = Context::from_waker(&waker);
- 121| |
- 122| | loop {
- 123| 1| if let Poll::Ready(val) = future.as_mut().poll(&mut context) {
- 124| 1| break val;
- 125| 0| }
- 126| | }
- 127| 1| }
- 128| |}
-
diff --git a/tests/run-make/coverage-reports/expected_show_coverage.async2.txt b/tests/run-make/coverage-reports/expected_show_coverage.async2.txt
deleted file mode 100644
index 500dde1f2..000000000
--- a/tests/run-make/coverage-reports/expected_show_coverage.async2.txt
+++ /dev/null
@@ -1,116 +0,0 @@
- 1| |// compile-flags: --edition=2018
- 2| |
- 3| |use core::{
- 4| | future::Future,
- 5| | marker::Send,
- 6| | pin::Pin,
- 7| |};
- 8| |
- 9| 1|fn non_async_func() {
- 10| 1| println!("non_async_func was covered");
- 11| 1| let b = true;
- 12| 1| if b {
- 13| 1| println!("non_async_func println in block");
- 14| 1| }
- ^0
- 15| 1|}
- 16| |
- 17| |
- 18| |
- 19| |
- 20| 1|async fn async_func() {
- 21| 1| println!("async_func was covered");
- 22| 1| let b = true;
- 23| 1| if b {
- 24| 1| println!("async_func println in block");
- 25| 1| }
- ^0
- 26| 1|}
- 27| |
- 28| |
- 29| |
- 30| |
- 31| 1|async fn async_func_just_println() {
- 32| 1| println!("async_func_just_println was covered");
- 33| 1|}
- 34| |
- 35| 1|fn main() {
- 36| 1| println!("codecovsample::main");
- 37| 1|
- 38| 1| non_async_func();
- 39| 1|
- 40| 1| executor::block_on(async_func());
- 41| 1| executor::block_on(async_func_just_println());
- 42| 1|}
- 43| |
- 44| |mod executor {
- 45| | use core::{
- 46| | future::Future,
- 47| | pin::Pin,
- 48| | task::{Context, Poll, RawWaker, RawWakerVTable, Waker},
- 49| | };
- 50| |
- 51| 2| pub fn block_on<F: Future>(mut future: F) -> F::Output {
- 52| 2| let mut future = unsafe { Pin::new_unchecked(&mut future) };
- 53| 2| use std::hint::unreachable_unchecked;
- 54| 2| static VTABLE: RawWakerVTable = RawWakerVTable::new(
- 55| 2| |_| unsafe { unreachable_unchecked() }, // clone
- ^0
- 56| 2| |_| unsafe { unreachable_unchecked() }, // wake
- ^0
- 57| 2| |_| unsafe { unreachable_unchecked() }, // wake_by_ref
- ^0
- 58| 2| |_| (),
- 59| 2| );
- 60| 2| let waker = unsafe { Waker::from_raw(RawWaker::new(core::ptr::null(), &VTABLE)) };
- 61| 2| let mut context = Context::from_waker(&waker);
- 62| |
- 63| | loop {
- 64| 2| if let Poll::Ready(val) = future.as_mut().poll(&mut context) {
- 65| 2| break val;
- 66| 0| }
- 67| | }
- 68| 2| }
- ------------------
- | async2::executor::block_on::<async2::async_func::{closure#0}>:
- | 51| 1| pub fn block_on<F: Future>(mut future: F) -> F::Output {
- | 52| 1| let mut future = unsafe { Pin::new_unchecked(&mut future) };
- | 53| 1| use std::hint::unreachable_unchecked;
- | 54| 1| static VTABLE: RawWakerVTable = RawWakerVTable::new(
- | 55| 1| |_| unsafe { unreachable_unchecked() }, // clone
- | 56| 1| |_| unsafe { unreachable_unchecked() }, // wake
- | 57| 1| |_| unsafe { unreachable_unchecked() }, // wake_by_ref
- | 58| 1| |_| (),
- | 59| 1| );
- | 60| 1| let waker = unsafe { Waker::from_raw(RawWaker::new(core::ptr::null(), &VTABLE)) };
- | 61| 1| let mut context = Context::from_waker(&waker);
- | 62| |
- | 63| | loop {
- | 64| 1| if let Poll::Ready(val) = future.as_mut().poll(&mut context) {
- | 65| 1| break val;
- | 66| 0| }
- | 67| | }
- | 68| 1| }
- ------------------
- | async2::executor::block_on::<async2::async_func_just_println::{closure#0}>:
- | 51| 1| pub fn block_on<F: Future>(mut future: F) -> F::Output {
- | 52| 1| let mut future = unsafe { Pin::new_unchecked(&mut future) };
- | 53| 1| use std::hint::unreachable_unchecked;
- | 54| 1| static VTABLE: RawWakerVTable = RawWakerVTable::new(
- | 55| 1| |_| unsafe { unreachable_unchecked() }, // clone
- | 56| 1| |_| unsafe { unreachable_unchecked() }, // wake
- | 57| 1| |_| unsafe { unreachable_unchecked() }, // wake_by_ref
- | 58| 1| |_| (),
- | 59| 1| );
- | 60| 1| let waker = unsafe { Waker::from_raw(RawWaker::new(core::ptr::null(), &VTABLE)) };
- | 61| 1| let mut context = Context::from_waker(&waker);
- | 62| |
- | 63| | loop {
- | 64| 1| if let Poll::Ready(val) = future.as_mut().poll(&mut context) {
- | 65| 1| break val;
- | 66| 0| }
- | 67| | }
- | 68| 1| }
- ------------------
- 69| |}
-
diff --git a/tests/run-make/coverage-reports/expected_show_coverage.closure.txt b/tests/run-make/coverage-reports/expected_show_coverage.closure.txt
deleted file mode 100644
index 002ecec3b..000000000
--- a/tests/run-make/coverage-reports/expected_show_coverage.closure.txt
+++ /dev/null
@@ -1,222 +0,0 @@
- 1| |#![allow(unused_assignments, unused_variables)]
- 2| |// compile-flags: -C opt-level=2 # fix described in rustc_middle/mir/mono.rs
- 3| 1|fn main() {
- 4| 1| // Initialize test constants in a way that cannot be determined at compile time, to ensure
- 5| 1| // rustc and LLVM cannot optimize out statements (or coverage counters) downstream from
- 6| 1| // dependent conditions.
- 7| 1| let is_true = std::env::args().len() == 1;
- 8| 1| let is_false = ! is_true;
- 9| 1|
- 10| 1| let mut some_string = Some(String::from("the string content"));
- 11| 1| println!(
- 12| 1| "The string or alt: {}"
- 13| 1| ,
- 14| 1| some_string
- 15| 1| .
- 16| 1| unwrap_or_else
- 17| 1| (
- 18| 1| ||
- 19| 0| {
- 20| 0| let mut countdown = 0;
- 21| 0| if is_false {
- 22| 0| countdown = 10;
- 23| 0| }
- 24| 0| "alt string 1".to_owned()
- 25| 1| }
- 26| 1| )
- 27| 1| );
- 28| 1|
- 29| 1| some_string = Some(String::from("the string content"));
- 30| 1| let
- 31| 1| a
- 32| | =
- 33| | ||
- 34| 0| {
- 35| 0| let mut countdown = 0;
- 36| 0| if is_false {
- 37| 0| countdown = 10;
- 38| 0| }
- 39| 0| "alt string 2".to_owned()
- 40| 0| };
- 41| 1| println!(
- 42| 1| "The string or alt: {}"
- 43| 1| ,
- 44| 1| some_string
- 45| 1| .
- 46| 1| unwrap_or_else
- 47| 1| (
- 48| 1| a
- 49| 1| )
- 50| 1| );
- 51| 1|
- 52| 1| some_string = None;
- 53| 1| println!(
- 54| 1| "The string or alt: {}"
- 55| 1| ,
- 56| 1| some_string
- 57| 1| .
- 58| 1| unwrap_or_else
- 59| 1| (
- 60| 1| ||
- 61| 1| {
- 62| 1| let mut countdown = 0;
- 63| 1| if is_false {
- 64| 0| countdown = 10;
- 65| 1| }
- 66| 1| "alt string 3".to_owned()
- 67| 1| }
- 68| 1| )
- 69| 1| );
- 70| 1|
- 71| 1| some_string = None;
- 72| 1| let
- 73| 1| a
- 74| 1| =
- 75| 1| ||
- 76| 1| {
- 77| 1| let mut countdown = 0;
- 78| 1| if is_false {
- 79| 0| countdown = 10;
- 80| 1| }
- 81| 1| "alt string 4".to_owned()
- 82| 1| };
- 83| 1| println!(
- 84| 1| "The string or alt: {}"
- 85| 1| ,
- 86| 1| some_string
- 87| 1| .
- 88| 1| unwrap_or_else
- 89| 1| (
- 90| 1| a
- 91| 1| )
- 92| 1| );
- 93| 1|
- 94| 1| let
- 95| 1| quote_closure
- 96| 1| =
- 97| 1| |val|
- 98| 5| {
- 99| 5| let mut countdown = 0;
- 100| 5| if is_false {
- 101| 0| countdown = 10;
- 102| 5| }
- 103| 5| format!("'{}'", val)
- 104| 5| };
- 105| 1| println!(
- 106| 1| "Repeated, quoted string: {:?}"
- 107| 1| ,
- 108| 1| std::iter::repeat("repeat me")
- 109| 1| .take(5)
- 110| 1| .map
- 111| 1| (
- 112| 1| quote_closure
- 113| 1| )
- 114| 1| .collect::<Vec<_>>()
- 115| 1| );
- 116| 1|
- 117| 1| let
- 118| 1| _unused_closure
- 119| | =
- 120| | |
- 121| | mut countdown
- 122| | |
- 123| 0| {
- 124| 0| if is_false {
- 125| 0| countdown = 10;
- 126| 0| }
- 127| 0| "closure should be unused".to_owned()
- 128| 0| };
- 129| |
- 130| 1| let mut countdown = 10;
- 131| 1| let _short_unused_closure = | _unused_arg: u8 | countdown += 1;
- ^0
- 132| |
- 133| |
- 134| 1| let short_used_covered_closure_macro = | used_arg: u8 | println!("called");
- 135| 1| let short_used_not_covered_closure_macro = | used_arg: u8 | println!("not called");
- ^0
- 136| 1| let _short_unused_closure_macro = | _unused_arg: u8 | println!("not called");
- ^0
- 137| |
- 138| |
- 139| |
- 140| |
- 141| 1| let _short_unused_closure_block = | _unused_arg: u8 | { println!("not called") };
- ^0
- 142| |
- 143| 1| let _shortish_unused_closure = | _unused_arg: u8 | {
- 144| 0| println!("not called")
- 145| 0| };
- 146| |
- 147| 1| let _as_short_unused_closure = |
- 148| | _unused_arg: u8
- 149| 0| | { println!("not called") };
- 150| |
- 151| 1| let _almost_as_short_unused_closure = |
- 152| | _unused_arg: u8
- 153| 0| | { println!("not called") }
- 154| | ;
- 155| |
- 156| |
- 157| |
- 158| |
- 159| |
- 160| 1| let _short_unused_closure_line_break_no_block = | _unused_arg: u8 |
- 161| 0|println!("not called")
- 162| | ;
- 163| |
- 164| 1| let _short_unused_closure_line_break_no_block2 =
- 165| | | _unused_arg: u8 |
- 166| 0| println!(
- 167| 0| "not called"
- 168| 0| )
- 169| | ;
- 170| |
- 171| 1| let short_used_not_covered_closure_line_break_no_block_embedded_branch =
- 172| | | _unused_arg: u8 |
- 173| 0| println!(
- 174| 0| "not called: {}",
- 175| 0| if is_true { "check" } else { "me" }
- 176| 0| )
- 177| | ;
- 178| |
- 179| 1| let short_used_not_covered_closure_line_break_block_embedded_branch =
- 180| 1| | _unused_arg: u8 |
- 181| 0| {
- 182| 0| println!(
- 183| 0| "not called: {}",
- 184| 0| if is_true { "check" } else { "me" }
- 185| | )
- 186| 0| }
- 187| | ;
- 188| |
- 189| 1| let short_used_covered_closure_line_break_no_block_embedded_branch =
- 190| 1| | _unused_arg: u8 |
- 191| 1| println!(
- 192| 1| "not called: {}",
- 193| 1| if is_true { "check" } else { "me" }
- ^0
- 194| 1| )
- 195| | ;
- 196| |
- 197| 1| let short_used_covered_closure_line_break_block_embedded_branch =
- 198| 1| | _unused_arg: u8 |
- 199| 1| {
- 200| 1| println!(
- 201| 1| "not called: {}",
- 202| 1| if is_true { "check" } else { "me" }
- ^0
- 203| | )
- 204| 1| }
- 205| | ;
- 206| |
- 207| 1| if is_false {
- 208| 0| short_used_not_covered_closure_macro(0);
- 209| 0| short_used_not_covered_closure_line_break_no_block_embedded_branch(0);
- 210| 0| short_used_not_covered_closure_line_break_block_embedded_branch(0);
- 211| 1| }
- 212| 1| short_used_covered_closure_macro(0);
- 213| 1| short_used_covered_closure_line_break_no_block_embedded_branch(0);
- 214| 1| short_used_covered_closure_line_break_block_embedded_branch(0);
- 215| 1|}
-
diff --git a/tests/run-make/coverage-reports/expected_show_coverage.closure_macro.txt b/tests/run-make/coverage-reports/expected_show_coverage.closure_macro.txt
deleted file mode 100644
index 87f701476..000000000
--- a/tests/run-make/coverage-reports/expected_show_coverage.closure_macro.txt
+++ /dev/null
@@ -1,42 +0,0 @@
- 1| |// compile-flags: --edition=2018
- 2| |#![feature(no_coverage)]
- 3| |
- 4| |macro_rules! bail {
- 5| | ($msg:literal $(,)?) => {
- 6| | if $msg.len() > 0 {
- 7| | println!("no msg");
- 8| | } else {
- 9| | println!($msg);
- 10| | }
- 11| | return Err(String::from($msg));
- 12| | };
- 13| |}
- 14| |
- 15| |macro_rules! on_error {
- 16| | ($value:expr, $error_message:expr) => {
- 17| | $value.or_else(|e| { // FIXME(85000): no coverage in closure macros
- 18| | let message = format!($error_message, e);
- 19| | if message.len() > 0 {
- 20| | println!("{}", message);
- 21| | Ok(String::from("ok"))
- 22| | } else {
- 23| | bail!("error");
- 24| | }
- 25| | })
- 26| | };
- 27| |}
- 28| |
- 29| 1|fn load_configuration_files() -> Result<String, String> {
- 30| 1| Ok(String::from("config"))
- 31| 1|}
- 32| |
- 33| 1|pub fn main() -> Result<(), String> {
- 34| 1| println!("Starting service");
- 35| 1| let config = on_error!(load_configuration_files(), "Error loading configs: {}")?;
- ^0
- 36| |
- 37| 1| let startup_delay_duration = String::from("arg");
- 38| 1| let _ = (config, startup_delay_duration);
- 39| 1| Ok(())
- 40| 1|}
-
diff --git a/tests/run-make/coverage-reports/expected_show_coverage.closure_macro_async.txt b/tests/run-make/coverage-reports/expected_show_coverage.closure_macro_async.txt
deleted file mode 100644
index 2b5418132..000000000
--- a/tests/run-make/coverage-reports/expected_show_coverage.closure_macro_async.txt
+++ /dev/null
@@ -1,83 +0,0 @@
- 1| |// compile-flags: --edition=2018
- 2| |#![feature(no_coverage)]
- 3| |
- 4| |macro_rules! bail {
- 5| | ($msg:literal $(,)?) => {
- 6| | if $msg.len() > 0 {
- 7| | println!("no msg");
- 8| | } else {
- 9| | println!($msg);
- 10| | }
- 11| | return Err(String::from($msg));
- 12| | };
- 13| |}
- 14| |
- 15| |macro_rules! on_error {
- 16| | ($value:expr, $error_message:expr) => {
- 17| | $value.or_else(|e| { // FIXME(85000): no coverage in closure macros
- 18| | let message = format!($error_message, e);
- 19| | if message.len() > 0 {
- 20| | println!("{}", message);
- 21| | Ok(String::from("ok"))
- 22| | } else {
- 23| | bail!("error");
- 24| | }
- 25| | })
- 26| | };
- 27| |}
- 28| |
- 29| 1|fn load_configuration_files() -> Result<String, String> {
- 30| 1| Ok(String::from("config"))
- 31| 1|}
- 32| |
- 33| 1|pub async fn test() -> Result<(), String> {
- 34| 1| println!("Starting service");
- 35| 1| let config = on_error!(load_configuration_files(), "Error loading configs: {}")?;
- ^0
- 36| |
- 37| 1| let startup_delay_duration = String::from("arg");
- 38| 1| let _ = (config, startup_delay_duration);
- 39| 1| Ok(())
- 40| 1|}
- 41| |
- 42| |#[no_coverage]
- 43| |fn main() {
- 44| | executor::block_on(test());
- 45| |}
- 46| |
- 47| |mod executor {
- 48| | use core::{
- 49| | future::Future,
- 50| | pin::Pin,
- 51| | task::{Context, Poll, RawWaker, RawWakerVTable, Waker},
- 52| | };
- 53| |
- 54| | #[no_coverage]
- 55| | pub fn block_on<F: Future>(mut future: F) -> F::Output {
- 56| | let mut future = unsafe { Pin::new_unchecked(&mut future) };
- 57| | use std::hint::unreachable_unchecked;
- 58| | static VTABLE: RawWakerVTable = RawWakerVTable::new(
- 59| |
- 60| | #[no_coverage]
- 61| | |_| unsafe { unreachable_unchecked() }, // clone
- 62| |
- 63| | #[no_coverage]
- 64| | |_| unsafe { unreachable_unchecked() }, // wake
- 65| |
- 66| | #[no_coverage]
- 67| | |_| unsafe { unreachable_unchecked() }, // wake_by_ref
- 68| |
- 69| | #[no_coverage]
- 70| | |_| (),
- 71| | );
- 72| | let waker = unsafe { Waker::from_raw(RawWaker::new(core::ptr::null(), &VTABLE)) };
- 73| | let mut context = Context::from_waker(&waker);
- 74| |
- 75| | loop {
- 76| | if let Poll::Ready(val) = future.as_mut().poll(&mut context) {
- 77| | break val;
- 78| | }
- 79| | }
- 80| | }
- 81| |}
-
diff --git a/tests/run-make/coverage-reports/expected_show_coverage.conditions.txt b/tests/run-make/coverage-reports/expected_show_coverage.conditions.txt
deleted file mode 100644
index 2d8a98a5d..000000000
--- a/tests/run-make/coverage-reports/expected_show_coverage.conditions.txt
+++ /dev/null
@@ -1,94 +0,0 @@
- 1| |#![allow(unused_assignments, unused_variables)]
- 2| |
- 3| 1|fn main() {
- 4| 1| let mut countdown = 0;
- 5| 1| if true {
- 6| 1| countdown = 10;
- 7| 1| }
- ^0
- 8| |
- 9| | const B: u32 = 100;
- 10| 1| let x = if countdown > 7 {
- 11| 1| countdown -= 4;
- 12| 1| B
- 13| 0| } else if countdown > 2 {
- 14| 0| if countdown < 1 || countdown > 5 || countdown != 9 {
- 15| 0| countdown = 0;
- 16| 0| }
- 17| 0| countdown -= 5;
- 18| 0| countdown
- 19| | } else {
- 20| 0| return;
- 21| | };
- 22| |
- 23| 1| let mut countdown = 0;
- 24| 1| if true {
- 25| 1| countdown = 10;
- 26| 1| }
- ^0
- 27| |
- 28| 1| if countdown > 7 {
- 29| 1| countdown -= 4;
- 30| 1| } else if countdown > 2 {
- ^0
- 31| 0| if countdown < 1 || countdown > 5 || countdown != 9 {
- 32| 0| countdown = 0;
- 33| 0| }
- 34| 0| countdown -= 5;
- 35| | } else {
- 36| 0| return;
- 37| | }
- 38| |
- 39| 1| if true {
- 40| 1| let mut countdown = 0;
- 41| 1| if true {
- 42| 1| countdown = 10;
- 43| 1| }
- ^0
- 44| |
- 45| 1| if countdown > 7 {
- 46| 1| countdown -= 4;
- 47| 1| }
- 48| 0| else if countdown > 2 {
- 49| 0| if countdown < 1 || countdown > 5 || countdown != 9 {
- 50| 0| countdown = 0;
- 51| 0| }
- 52| 0| countdown -= 5;
- 53| | } else {
- 54| 0| return;
- 55| | }
- 56| 0| }
- 57| |
- 58| |
- 59| 1| let mut countdown = 0;
- 60| 1| if true {
- 61| 1| countdown = 1;
- 62| 1| }
- ^0
- 63| |
- 64| 1| let z = if countdown > 7 {
- ^0
- 65| 0| countdown -= 4;
- 66| 1| } else if countdown > 2 {
- 67| 0| if countdown < 1 || countdown > 5 || countdown != 9 {
- 68| 0| countdown = 0;
- 69| 0| }
- 70| 0| countdown -= 5;
- 71| | } else {
- 72| 1| let should_be_reachable = countdown;
- 73| 1| println!("reached");
- 74| 1| return;
- 75| | };
- 76| |
- 77| 0| let w = if countdown > 7 {
- 78| 0| countdown -= 4;
- 79| 0| } else if countdown > 2 {
- 80| 0| if countdown < 1 || countdown > 5 || countdown != 9 {
- 81| 0| countdown = 0;
- 82| 0| }
- 83| 0| countdown -= 5;
- 84| | } else {
- 85| 0| return;
- 86| | };
- 87| 1|}
-
diff --git a/tests/run-make/coverage-reports/expected_show_coverage.continue.txt b/tests/run-make/coverage-reports/expected_show_coverage.continue.txt
deleted file mode 100644
index bf42924b1..000000000
--- a/tests/run-make/coverage-reports/expected_show_coverage.continue.txt
+++ /dev/null
@@ -1,70 +0,0 @@
- 1| |#![allow(unused_assignments, unused_variables)]
- 2| |
- 3| 1|fn main() {
- 4| 1| let is_true = std::env::args().len() == 1;
- 5| 1|
- 6| 1| let mut x = 0;
- 7| 11| for _ in 0..10 {
- 8| 10| match is_true {
- 9| | true => {
- 10| 10| continue;
- 11| | }
- 12| 0| _ => {
- 13| 0| x = 1;
- 14| 0| }
- 15| 0| }
- 16| 0| x = 3;
- 17| | }
- 18| 11| for _ in 0..10 {
- 19| 10| match is_true {
- 20| 0| false => {
- 21| 0| x = 1;
- 22| 0| }
- 23| | _ => {
- 24| 10| continue;
- 25| | }
- 26| | }
- 27| 0| x = 3;
- 28| | }
- 29| 11| for _ in 0..10 {
- 30| 10| match is_true {
- 31| 10| true => {
- 32| 10| x = 1;
- 33| 10| }
- 34| | _ => {
- 35| 0| continue;
- 36| | }
- 37| | }
- 38| 10| x = 3;
- 39| | }
- 40| 11| for _ in 0..10 {
- 41| 10| if is_true {
- 42| 10| continue;
- 43| 0| }
- 44| 0| x = 3;
- 45| | }
- 46| 11| for _ in 0..10 {
- 47| 10| match is_true {
- 48| 0| false => {
- 49| 0| x = 1;
- 50| 0| }
- 51| 10| _ => {
- 52| 10| let _ = x;
- 53| 10| }
- 54| | }
- 55| 10| x = 3;
- 56| | }
- 57| 1| for _ in 0..10 {
- 58| 1| match is_true {
- 59| 0| false => {
- 60| 0| x = 1;
- 61| 0| }
- 62| | _ => {
- 63| 1| break;
- 64| | }
- 65| | }
- 66| 0| x = 3;
- 67| | }
- 68| 1| let _ = x;
- 69| 1|}
-
diff --git a/tests/run-make/coverage-reports/expected_show_coverage.dead_code.txt b/tests/run-make/coverage-reports/expected_show_coverage.dead_code.txt
deleted file mode 100644
index 09ff14c6f..000000000
--- a/tests/run-make/coverage-reports/expected_show_coverage.dead_code.txt
+++ /dev/null
@@ -1,39 +0,0 @@
- 1| |#![allow(unused_assignments, unused_variables)]
- 2| |
- 3| 0|pub fn unused_pub_fn_not_in_library() {
- 4| 0| // Initialize test constants in a way that cannot be determined at compile time, to ensure
- 5| 0| // rustc and LLVM cannot optimize out statements (or coverage counters) downstream from
- 6| 0| // dependent conditions.
- 7| 0| let is_true = std::env::args().len() == 1;
- 8| 0|
- 9| 0| let mut countdown = 0;
- 10| 0| if is_true {
- 11| 0| countdown = 10;
- 12| 0| }
- 13| 0|}
- 14| |
- 15| 0|fn unused_fn() {
- 16| 0| // Initialize test constants in a way that cannot be determined at compile time, to ensure
- 17| 0| // rustc and LLVM cannot optimize out statements (or coverage counters) downstream from
- 18| 0| // dependent conditions.
- 19| 0| let is_true = std::env::args().len() == 1;
- 20| 0|
- 21| 0| let mut countdown = 0;
- 22| 0| if is_true {
- 23| 0| countdown = 10;
- 24| 0| }
- 25| 0|}
- 26| |
- 27| 1|fn main() {
- 28| 1| // Initialize test constants in a way that cannot be determined at compile time, to ensure
- 29| 1| // rustc and LLVM cannot optimize out statements (or coverage counters) downstream from
- 30| 1| // dependent conditions.
- 31| 1| let is_true = std::env::args().len() == 1;
- 32| 1|
- 33| 1| let mut countdown = 0;
- 34| 1| if is_true {
- 35| 1| countdown = 10;
- 36| 1| }
- ^0
- 37| 1|}
-
diff --git a/tests/run-make/coverage-reports/expected_show_coverage.doctest.txt b/tests/run-make/coverage-reports/expected_show_coverage.doctest.txt
deleted file mode 100644
index 732de6526..000000000
--- a/tests/run-make/coverage-reports/expected_show_coverage.doctest.txt
+++ /dev/null
@@ -1,115 +0,0 @@
-../coverage/doctest.rs:
- 1| |//! This test ensures that code from doctests is properly re-mapped.
- 2| |//! See <https://github.com/rust-lang/rust/issues/79417> for more info.
- 3| |//!
- 4| |//! Just some random code:
- 5| 1|//! ```
- 6| 1|//! if true {
- 7| |//! // this is executed!
- 8| 1|//! assert_eq!(1, 1);
- 9| |//! } else {
- 10| |//! // this is not!
- 11| 0|//! assert_eq!(1, 2);
- 12| |//! }
- 13| 1|//! ```
- 14| |//!
- 15| |//! doctest testing external code:
- 16| |//! ```
- 17| 1|//! extern crate doctest_crate;
- 18| 1|//! doctest_crate::fn_run_in_doctests(1);
- 19| 1|//! ```
- 20| |//!
- 21| |//! doctest returning a result:
- 22| 1|//! ```
- 23| 2|//! #[derive(Debug, PartialEq)]
- ^1
- 24| 1|//! struct SomeError {
- 25| 1|//! msg: String,
- 26| 1|//! }
- 27| 1|//! let mut res = Err(SomeError { msg: String::from("a message") });
- 28| 1|//! if res.is_ok() {
- 29| 0|//! res?;
- 30| |//! } else {
- 31| 1|//! if *res.as_ref().unwrap_err() == *res.as_ref().unwrap_err() {
- 32| 1|//! println!("{:?}", res);
- 33| 1|//! }
- ^0
- 34| 1|//! if *res.as_ref().unwrap_err() == *res.as_ref().unwrap_err() {
- 35| 1|//! res = Ok(1);
- 36| 1|//! }
- ^0
- 37| 1|//! res = Ok(0);
- 38| |//! }
- 39| |//! // need to be explicit because rustdoc cant infer the return type
- 40| 1|//! Ok::<(), SomeError>(())
- 41| 1|//! ```
- 42| |//!
- 43| |//! doctest with custom main:
- 44| |//! ```
- 45| 1|//! fn some_func() {
- 46| 1|//! println!("called some_func()");
- 47| 1|//! }
- 48| |//!
- 49| 0|//! #[derive(Debug)]
- 50| |//! struct SomeError;
- 51| |//!
- 52| |//! extern crate doctest_crate;
- 53| |//!
- 54| 1|//! fn doctest_main() -> Result<(), SomeError> {
- 55| 1|//! some_func();
- 56| 1|//! doctest_crate::fn_run_in_doctests(2);
- 57| 1|//! Ok(())
- 58| 1|//! }
- 59| |//!
- 60| |//! // this `main` is not shown as covered, as it clashes with all the other
- 61| |//! // `main` functions that were automatically generated for doctests
- 62| |//! fn main() -> Result<(), SomeError> {
- 63| |//! doctest_main()
- 64| |//! }
- 65| |//! ```
- 66| |
- 67| |/// doctest attached to fn testing external code:
- 68| |/// ```
- 69| 1|/// extern crate doctest_crate;
- 70| 1|/// doctest_crate::fn_run_in_doctests(3);
- 71| 1|/// ```
- 72| |///
- 73| 1|fn main() {
- 74| 1| if true {
- 75| 1| assert_eq!(1, 1);
- 76| | } else {
- 77| 0| assert_eq!(1, 2);
- 78| | }
- 79| 1|}
- 80| |
- 81| |// FIXME(Swatinem): Fix known issue that coverage code region columns need to be offset by the
- 82| |// doc comment line prefix (`///` or `//!`) and any additional indent (before or after the doc
- 83| |// comment characters). This test produces `llvm-cov show` results demonstrating the problem.
- 84| |//
- 85| |// One of the above tests now includes: `derive(Debug, PartialEq)`, producing an `llvm-cov show`
- 86| |// result with a distinct count for `Debug`, denoted by `^1`, but the caret points to the wrong
- 87| |// column. Similarly, the `if` blocks without `else` blocks show `^0`, which should point at, or
- 88| |// one character past, the `if` block's closing brace. In both cases, these are most likely off
- 89| |// by the number of characters stripped from the beginning of each doc comment line: indent
- 90| |// whitespace, if any, doc comment prefix (`//!` in this case) and (I assume) one space character
- 91| |// (?). Note, when viewing `llvm-cov show` results in `--color` mode, the column offset errors are
- 92| |// more pronounced, and show up in more places, with background color used to show some distinct
- 93| |// code regions with different coverage counts.
- 94| |//
- 95| |// NOTE: Since the doc comment line prefix may vary, one possible solution is to replace each
- 96| |// character stripped from the beginning of doc comment lines with a space. This will give coverage
- 97| |// results the correct column offsets, and I think it should compile correctly, but I don't know
- 98| |// what affect it might have on diagnostic messages from the compiler, and whether anyone would care
- 99| |// if the indentation changed. I don't know if there is a more viable solution.
-
-../coverage/lib/doctest_crate.rs:
- 1| |/// A function run only from within doctests
- 2| 3|pub fn fn_run_in_doctests(conditional: usize) {
- 3| 3| match conditional {
- 4| 1| 1 => assert_eq!(1, 1), // this is run,
- 5| 1| 2 => assert_eq!(1, 1), // this,
- 6| 1| 3 => assert_eq!(1, 1), // and this too
- 7| 0| _ => assert_eq!(1, 2), // however this is not
- 8| | }
- 9| 3|}
-
diff --git a/tests/run-make/coverage-reports/expected_show_coverage.drop_trait.txt b/tests/run-make/coverage-reports/expected_show_coverage.drop_trait.txt
deleted file mode 100644
index fe6a9e93c..000000000
--- a/tests/run-make/coverage-reports/expected_show_coverage.drop_trait.txt
+++ /dev/null
@@ -1,34 +0,0 @@
- 1| |#![allow(unused_assignments)]
- 2| |// expect-exit-status-1
- 3| |
- 4| |struct Firework {
- 5| | strength: i32,
- 6| |}
- 7| |
- 8| |impl Drop for Firework {
- 9| 2| fn drop(&mut self) {
- 10| 2| println!("BOOM times {}!!!", self.strength);
- 11| 2| }
- 12| |}
- 13| |
- 14| 1|fn main() -> Result<(),u8> {
- 15| 1| let _firecracker = Firework { strength: 1 };
- 16| 1|
- 17| 1| let _tnt = Firework { strength: 100 };
- 18| 1|
- 19| 1| if true {
- 20| 1| println!("Exiting with error...");
- 21| 1| return Err(1);
- 22| 0| }
- 23| 0|
- 24| 0| let _ = Firework { strength: 1000 };
- 25| 0|
- 26| 0| Ok(())
- 27| 1|}
- 28| |
- 29| |// Expected program output:
- 30| |// Exiting with error...
- 31| |// BOOM times 100!!!
- 32| |// BOOM times 1!!!
- 33| |// Error: 1
-
diff --git a/tests/run-make/coverage-reports/expected_show_coverage.generator.txt b/tests/run-make/coverage-reports/expected_show_coverage.generator.txt
deleted file mode 100644
index 0fb3808ff..000000000
--- a/tests/run-make/coverage-reports/expected_show_coverage.generator.txt
+++ /dev/null
@@ -1,32 +0,0 @@
- 1| |#![feature(generators, generator_trait)]
- 2| |
- 3| |use std::ops::{Generator, GeneratorState};
- 4| |use std::pin::Pin;
- 5| |
- 6| |// The following implementation of a function called from a `yield` statement
- 7| |// (apparently requiring the Result and the `String` type or constructor)
- 8| |// creates conditions where the `generator::StateTransform` MIR transform will
- 9| |// drop all `Counter` `Coverage` statements from a MIR. `simplify.rs` has logic
- 10| |// to handle this condition, and still report dead block coverage.
- 11| 1|fn get_u32(val: bool) -> Result<u32, String> {
- 12| 1| if val { Ok(1) } else { Err(String::from("some error")) }
- ^0
- 13| 1|}
- 14| |
- 15| 1|fn main() {
- 16| 1| let is_true = std::env::args().len() == 1;
- 17| 1| let mut generator = || {
- 18| 1| yield get_u32(is_true);
- 19| 1| return "foo";
- 20| 1| };
- 21| |
- 22| 1| match Pin::new(&mut generator).resume(()) {
- 23| 1| GeneratorState::Yielded(Ok(1)) => {}
- 24| 0| _ => panic!("unexpected return from resume"),
- 25| | }
- 26| 1| match Pin::new(&mut generator).resume(()) {
- 27| 1| GeneratorState::Complete("foo") => {}
- 28| 0| _ => panic!("unexpected return from resume"),
- 29| | }
- 30| 1|}
-
diff --git a/tests/run-make/coverage-reports/expected_show_coverage.generics.txt b/tests/run-make/coverage-reports/expected_show_coverage.generics.txt
deleted file mode 100644
index 7eb33a29a..000000000
--- a/tests/run-make/coverage-reports/expected_show_coverage.generics.txt
+++ /dev/null
@@ -1,71 +0,0 @@
- 1| |#![allow(unused_assignments)]
- 2| |// expect-exit-status-1
- 3| |
- 4| |struct Firework<T> where T: Copy + std::fmt::Display {
- 5| | strength: T,
- 6| |}
- 7| |
- 8| |impl<T> Firework<T> where T: Copy + std::fmt::Display {
- 9| | #[inline(always)]
- 10| 3| fn set_strength(&mut self, new_strength: T) {
- 11| 3| self.strength = new_strength;
- 12| 3| }
- ------------------
- | <generics::Firework<f64>>::set_strength:
- | 10| 2| fn set_strength(&mut self, new_strength: T) {
- | 11| 2| self.strength = new_strength;
- | 12| 2| }
- ------------------
- | <generics::Firework<i32>>::set_strength:
- | 10| 1| fn set_strength(&mut self, new_strength: T) {
- | 11| 1| self.strength = new_strength;
- | 12| 1| }
- ------------------
- 13| |}
- 14| |
- 15| |impl<T> Drop for Firework<T> where T: Copy + std::fmt::Display {
- 16| | #[inline(always)]
- 17| 2| fn drop(&mut self) {
- 18| 2| println!("BOOM times {}!!!", self.strength);
- 19| 2| }
- ------------------
- | <generics::Firework<f64> as core::ops::drop::Drop>::drop:
- | 17| 1| fn drop(&mut self) {
- | 18| 1| println!("BOOM times {}!!!", self.strength);
- | 19| 1| }
- ------------------
- | <generics::Firework<i32> as core::ops::drop::Drop>::drop:
- | 17| 1| fn drop(&mut self) {
- | 18| 1| println!("BOOM times {}!!!", self.strength);
- | 19| 1| }
- ------------------
- 20| |}
- 21| |
- 22| 1|fn main() -> Result<(),u8> {
- 23| 1| let mut firecracker = Firework { strength: 1 };
- 24| 1| firecracker.set_strength(2);
- 25| 1|
- 26| 1| let mut tnt = Firework { strength: 100.1 };
- 27| 1| tnt.set_strength(200.1);
- 28| 1| tnt.set_strength(300.3);
- 29| 1|
- 30| 1| if true {
- 31| 1| println!("Exiting with error...");
- 32| 1| return Err(1);
- 33| 0| }
- 34| 0|
- 35| 0|
- 36| 0|
- 37| 0|
- 38| 0|
- 39| 0| let _ = Firework { strength: 1000 };
- 40| 0|
- 41| 0| Ok(())
- 42| 1|}
- 43| |
- 44| |// Expected program output:
- 45| |// Exiting with error...
- 46| |// BOOM times 100!!!
- 47| |// BOOM times 1!!!
- 48| |// Error: 1
-
diff --git a/tests/run-make/coverage-reports/expected_show_coverage.if.txt b/tests/run-make/coverage-reports/expected_show_coverage.if.txt
deleted file mode 100644
index 0c9eff227..000000000
--- a/tests/run-make/coverage-reports/expected_show_coverage.if.txt
+++ /dev/null
@@ -1,30 +0,0 @@
- 1| |#![allow(unused_assignments, unused_variables)]
- 2| |
- 3| 1|fn main() {
- 4| 1| // Initialize test constants in a way that cannot be determined at compile time, to ensure
- 5| 1| // rustc and LLVM cannot optimize out statements (or coverage counters) downstream from
- 6| 1| // dependent conditions.
- 7| 1| let
- 8| 1| is_true
- 9| 1| =
- 10| 1| std::env::args().len()
- 11| 1| ==
- 12| 1| 1
- 13| 1| ;
- 14| 1| let
- 15| 1| mut
- 16| 1| countdown
- 17| 1| =
- 18| 1| 0
- 19| 1| ;
- 20| 1| if
- 21| 1| is_true
- 22| 1| {
- 23| 1| countdown
- 24| 1| =
- 25| 1| 10
- 26| 1| ;
- 27| 1| }
- ^0
- 28| 1|}
-
diff --git a/tests/run-make/coverage-reports/expected_show_coverage.if_else.txt b/tests/run-make/coverage-reports/expected_show_coverage.if_else.txt
deleted file mode 100644
index 4285d3186..000000000
--- a/tests/run-make/coverage-reports/expected_show_coverage.if_else.txt
+++ /dev/null
@@ -1,41 +0,0 @@
- 1| |#![allow(unused_assignments, unused_variables)]
- 2| |
- 3| 1|fn main() {
- 4| 1| // Initialize test constants in a way that cannot be determined at compile time, to ensure
- 5| 1| // rustc and LLVM cannot optimize out statements (or coverage counters) downstream from
- 6| 1| // dependent conditions.
- 7| 1| let is_true = std::env::args().len() == 1;
- 8| 1|
- 9| 1| let mut countdown = 0;
- 10| 1| if
- 11| 1| is_true
- 12| 1| {
- 13| 1| countdown
- 14| 1| =
- 15| 1| 10
- 16| 1| ;
- 17| 1| }
- 18| | else // Note coverage region difference without semicolon
- 19| | {
- 20| 0| countdown
- 21| 0| =
- 22| 0| 100
- 23| | }
- 24| |
- 25| | if
- 26| 1| is_true
- 27| 1| {
- 28| 1| countdown
- 29| 1| =
- 30| 1| 10
- 31| 1| ;
- 32| 1| }
- 33| | else
- 34| 0| {
- 35| 0| countdown
- 36| 0| =
- 37| 0| 100
- 38| 0| ;
- 39| 0| }
- 40| 1|}
-
diff --git a/tests/run-make/coverage-reports/expected_show_coverage.inline-dead.txt b/tests/run-make/coverage-reports/expected_show_coverage.inline-dead.txt
deleted file mode 100644
index a59fe1146..000000000
--- a/tests/run-make/coverage-reports/expected_show_coverage.inline-dead.txt
+++ /dev/null
@@ -1,28 +0,0 @@
- 1| |// Regression test for issue #98833.
- 2| |// compile-flags: -Zinline-mir -Cdebug-assertions=off
- 3| |
- 4| 1|fn main() {
- 5| 1| println!("{}", live::<false>());
- 6| 1|
- 7| 1| let f = |x: bool| {
- 8| | debug_assert!(
- 9| 0| x
- 10| | );
- 11| 1| };
- 12| 1| f(false);
- 13| 1|}
- 14| |
- 15| |#[inline]
- 16| 1|fn live<const B: bool>() -> u32 {
- 17| 1| if B {
- 18| 0| dead()
- 19| | } else {
- 20| 1| 0
- 21| | }
- 22| 1|}
- 23| |
- 24| |#[inline]
- 25| 0|fn dead() -> u32 {
- 26| 0| 42
- 27| 0|}
-
diff --git a/tests/run-make/coverage-reports/expected_show_coverage.inline.txt b/tests/run-make/coverage-reports/expected_show_coverage.inline.txt
deleted file mode 100644
index 6f5d1544f..000000000
--- a/tests/run-make/coverage-reports/expected_show_coverage.inline.txt
+++ /dev/null
@@ -1,54 +0,0 @@
- 1| |// compile-flags: -Zinline-mir
- 2| |
- 3| |use std::fmt::Display;
- 4| |
- 5| 1|fn main() {
- 6| 1| permutations(&['a', 'b', 'c']);
- 7| 1|}
- 8| |
- 9| |#[inline(always)]
- 10| 1|fn permutations<T: Copy + Display>(xs: &[T]) {
- 11| 1| let mut ys = xs.to_owned();
- 12| 1| permutate(&mut ys, 0);
- 13| 1|}
- 14| |
- 15| 16|fn permutate<T: Copy + Display>(xs: &mut [T], k: usize) {
- 16| 16| let n = length(xs);
- 17| 16| if k == n {
- 18| 6| display(xs);
- 19| 10| } else if k < n {
- 20| 15| for i in k..n {
- ^10
- 21| 15| swap(xs, i, k);
- 22| 15| permutate(xs, k + 1);
- 23| 15| swap(xs, i, k);
- 24| 15| }
- 25| 0| } else {
- 26| 0| error();
- 27| 0| }
- 28| 16|}
- 29| |
- 30| 16|fn length<T>(xs: &[T]) -> usize {
- 31| 16| xs.len()
- 32| 16|}
- 33| |
- 34| |#[inline]
- 35| 30|fn swap<T: Copy>(xs: &mut [T], i: usize, j: usize) {
- 36| 30| let t = xs[i];
- 37| 30| xs[i] = xs[j];
- 38| 30| xs[j] = t;
- 39| 30|}
- 40| |
- 41| 6|fn display<T: Display>(xs: &[T]) {
- 42| 24| for x in xs {
- ^18
- 43| 18| print!("{}", x);
- 44| 18| }
- 45| 6| println!();
- 46| 6|}
- 47| |
- 48| |#[inline(always)]
- 49| 0|fn error() {
- 50| 0| panic!("error");
- 51| 0|}
-
diff --git a/tests/run-make/coverage-reports/expected_show_coverage.inner_items.txt b/tests/run-make/coverage-reports/expected_show_coverage.inner_items.txt
deleted file mode 100644
index 883254a09..000000000
--- a/tests/run-make/coverage-reports/expected_show_coverage.inner_items.txt
+++ /dev/null
@@ -1,60 +0,0 @@
- 1| |#![allow(unused_assignments, unused_variables, dead_code)]
- 2| |
- 3| 1|fn main() {
- 4| 1| // Initialize test constants in a way that cannot be determined at compile time, to ensure
- 5| 1| // rustc and LLVM cannot optimize out statements (or coverage counters) downstream from
- 6| 1| // dependent conditions.
- 7| 1| let is_true = std::env::args().len() == 1;
- 8| 1|
- 9| 1| let mut countdown = 0;
- 10| 1| if is_true {
- 11| 1| countdown = 10;
- 12| 1| }
- ^0
- 13| |
- 14| | mod in_mod {
- 15| | const IN_MOD_CONST: u32 = 1000;
- 16| | }
- 17| |
- 18| 3| fn in_func(a: u32) {
- 19| 3| let b = 1;
- 20| 3| let c = a + b;
- 21| 3| println!("c = {}", c)
- 22| 3| }
- 23| |
- 24| | struct InStruct {
- 25| | in_struct_field: u32,
- 26| | }
- 27| |
- 28| | const IN_CONST: u32 = 1234;
- 29| |
- 30| | trait InTrait {
- 31| | fn trait_func(&mut self, incr: u32);
- 32| |
- 33| 1| fn default_trait_func(&mut self) {
- 34| 1| in_func(IN_CONST);
- 35| 1| self.trait_func(IN_CONST);
- 36| 1| }
- 37| | }
- 38| |
- 39| | impl InTrait for InStruct {
- 40| 1| fn trait_func(&mut self, incr: u32) {
- 41| 1| self.in_struct_field += incr;
- 42| 1| in_func(self.in_struct_field);
- 43| 1| }
- 44| | }
- 45| |
- 46| | type InType = String;
- 47| |
- 48| 1| if is_true {
- 49| 1| in_func(countdown);
- 50| 1| }
- ^0
- 51| |
- 52| 1| let mut val = InStruct {
- 53| 1| in_struct_field: 101,
- 54| 1| };
- 55| 1|
- 56| 1| val.default_trait_func();
- 57| 1|}
-
diff --git a/tests/run-make/coverage-reports/expected_show_coverage.issue-83601.txt b/tests/run-make/coverage-reports/expected_show_coverage.issue-83601.txt
deleted file mode 100644
index 25c74ab2e..000000000
--- a/tests/run-make/coverage-reports/expected_show_coverage.issue-83601.txt
+++ /dev/null
@@ -1,16 +0,0 @@
- 1| |// Shows that rust-lang/rust/83601 is resolved
- 2| |
- 3| 3|#[derive(Debug, PartialEq, Eq)]
- ^2
- 4| |struct Foo(u32);
- 5| |
- 6| 1|fn main() {
- 7| 1| let bar = Foo(1);
- 8| 1| assert_eq!(bar, Foo(1));
- 9| 1| let baz = Foo(0);
- 10| 1| assert_ne!(baz, Foo(1));
- 11| 1| println!("{:?}", Foo(1));
- 12| 1| println!("{:?}", bar);
- 13| 1| println!("{:?}", baz);
- 14| 1|}
-
diff --git a/tests/run-make/coverage-reports/expected_show_coverage.issue-84561.txt b/tests/run-make/coverage-reports/expected_show_coverage.issue-84561.txt
deleted file mode 100644
index 4a60432c1..000000000
--- a/tests/run-make/coverage-reports/expected_show_coverage.issue-84561.txt
+++ /dev/null
@@ -1,189 +0,0 @@
- 1| |// This demonstrated Issue #84561: function-like macros produce unintuitive coverage results.
- 2| |
- 3| |// expect-exit-status-101
- 4| 21|#[derive(PartialEq, Eq)]
- 5| |struct Foo(u32);
- 6| 1|fn test3() {
- 7| 1| let is_true = std::env::args().len() == 1;
- 8| 1| let bar = Foo(1);
- 9| 1| assert_eq!(bar, Foo(1));
- 10| 1| let baz = Foo(0);
- 11| 1| assert_ne!(baz, Foo(1));
- 12| 1| println!("{:?}", Foo(1));
- 13| 1| println!("{:?}", bar);
- 14| 1| println!("{:?}", baz);
- 15| 1|
- 16| 1| assert_eq!(Foo(1), Foo(1));
- 17| 1| assert_ne!(Foo(0), Foo(1));
- 18| 1| assert_eq!(Foo(2), Foo(2));
- 19| 1| let bar = Foo(0);
- 20| 1| assert_ne!(bar, Foo(3));
- 21| 1| assert_ne!(Foo(0), Foo(4));
- 22| 1| assert_eq!(Foo(3), Foo(3), "with a message");
- ^0
- 23| 1| println!("{:?}", bar);
- 24| 1| println!("{:?}", Foo(1));
- 25| 1|
- 26| 1| assert_ne!(Foo(0), Foo(5), "{}", if is_true { "true message" } else { "false message" });
- ^0 ^0 ^0
- 27| 1| assert_ne!(
- 28| | Foo(0)
- 29| | ,
- 30| | Foo(5)
- 31| | ,
- 32| 0| "{}"
- 33| 0| ,
- 34| 0| if
- 35| 0| is_true
- 36| | {
- 37| 0| "true message"
- 38| | } else {
- 39| 0| "false message"
- 40| | }
- 41| | );
- 42| |
- 43| 1| let is_true = std::env::args().len() == 1;
- 44| 1|
- 45| 1| assert_eq!(
- 46| 1| Foo(1),
- 47| 1| Foo(1)
- 48| 1| );
- 49| 1| assert_ne!(
- 50| 1| Foo(0),
- 51| 1| Foo(1)
- 52| 1| );
- 53| 1| assert_eq!(
- 54| 1| Foo(2),
- 55| 1| Foo(2)
- 56| 1| );
- 57| 1| let bar = Foo(1);
- 58| 1| assert_ne!(
- 59| 1| bar,
- 60| 1| Foo(3)
- 61| 1| );
- 62| 1| if is_true {
- 63| 1| assert_ne!(
- 64| 1| Foo(0),
- 65| 1| Foo(4)
- 66| 1| );
- 67| | } else {
- 68| 0| assert_eq!(
- 69| 0| Foo(3),
- 70| 0| Foo(3)
- 71| 0| );
- 72| | }
- 73| 1| if is_true {
- 74| 1| assert_ne!(
- 75| | Foo(0),
- 76| | Foo(4),
- 77| 0| "with a message"
- 78| | );
- 79| | } else {
- 80| 0| assert_eq!(
- 81| | Foo(3),
- 82| | Foo(3),
- 83| 0| "with a message"
- 84| | );
- 85| | }
- 86| 1| assert_ne!(
- 87| 1| if is_true {
- 88| 1| Foo(0)
- 89| | } else {
- 90| 0| Foo(1)
- 91| | },
- 92| | Foo(5)
- 93| | );
- 94| 1| assert_ne!(
- 95| 1| Foo(5),
- 96| 1| if is_true {
- 97| 1| Foo(0)
- 98| | } else {
- 99| 0| Foo(1)
- 100| | }
- 101| | );
- 102| 1| assert_ne!(
- 103| 1| if is_true {
- 104| 1| assert_eq!(
- 105| 1| Foo(3),
- 106| 1| Foo(3)
- 107| 1| );
- 108| 1| Foo(0)
- 109| | } else {
- 110| 0| assert_ne!(
- 111| 0| if is_true {
- 112| 0| Foo(0)
- 113| | } else {
- 114| 0| Foo(1)
- 115| | },
- 116| | Foo(5)
- 117| | );
- 118| 0| Foo(1)
- 119| | },
- 120| | Foo(5),
- 121| 0| "with a message"
- 122| | );
- 123| 1| assert_eq!(
- 124| | Foo(1),
- 125| | Foo(3),
- 126| 1| "this assert should fail"
- 127| | );
- 128| 0| assert_eq!(
- 129| | Foo(3),
- 130| | Foo(3),
- 131| 0| "this assert should not be reached"
- 132| | );
- 133| 0|}
- 134| |
- 135| |impl std::fmt::Debug for Foo {
- 136| | fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
- 137| 7| write!(f, "try and succeed")?;
- ^0
- 138| 7| Ok(())
- 139| 7| }
- 140| |}
- 141| |
- 142| |static mut DEBUG_LEVEL_ENABLED: bool = false;
- 143| |
- 144| |macro_rules! debug {
- 145| | ($($arg:tt)+) => (
- 146| | if unsafe { DEBUG_LEVEL_ENABLED } {
- 147| | println!($($arg)+);
- 148| | }
- 149| | );
- 150| |}
- 151| |
- 152| 1|fn test1() {
- 153| 1| debug!("debug is enabled");
- ^0
- 154| 1| debug!("debug is enabled");
- ^0
- 155| 1| let _ = 0;
- 156| 1| debug!("debug is enabled");
- ^0
- 157| 1| unsafe {
- 158| 1| DEBUG_LEVEL_ENABLED = true;
- 159| 1| }
- 160| 1| debug!("debug is enabled");
- 161| 1|}
- 162| |
- 163| |macro_rules! call_debug {
- 164| | ($($arg:tt)+) => (
- 165| 1| fn call_print(s: &str) {
- 166| 1| print!("{}", s);
- 167| 1| }
- 168| |
- 169| | call_print("called from call_debug: ");
- 170| | debug!($($arg)+);
- 171| | );
- 172| |}
- 173| |
- 174| 1|fn test2() {
- 175| 1| call_debug!("debug is enabled");
- 176| 1|}
- 177| |
- 178| 1|fn main() {
- 179| 1| test1();
- 180| 1| test2();
- 181| 1| test3();
- 182| 1|}
-
diff --git a/tests/run-make/coverage-reports/expected_show_coverage.issue-85461.txt b/tests/run-make/coverage-reports/expected_show_coverage.issue-85461.txt
deleted file mode 100644
index 1aa4a22c3..000000000
--- a/tests/run-make/coverage-reports/expected_show_coverage.issue-85461.txt
+++ /dev/null
@@ -1,36 +0,0 @@
-../coverage/issue-85461.rs:
- 1| |// Regression test for #85461: MSVC sometimes fail to link with dead code and #[inline(always)]
- 2| |
- 3| |extern crate inline_always_with_dead_code;
- 4| |
- 5| |use inline_always_with_dead_code::{bar, baz};
- 6| |
- 7| 1|fn main() {
- 8| 1| bar::call_me();
- 9| 1| baz::call_me();
- 10| 1|}
-
-../coverage/lib/inline_always_with_dead_code.rs:
- 1| |// compile-flags: -Cinstrument-coverage -Ccodegen-units=4 -Copt-level=0
- 2| |
- 3| |#![allow(dead_code)]
- 4| |
- 5| |mod foo {
- 6| | #[inline(always)]
- 7| 2| pub fn called() { }
- 8| |
- 9| 0| fn uncalled() { }
- 10| |}
- 11| |
- 12| |pub mod bar {
- 13| 1| pub fn call_me() {
- 14| 1| super::foo::called();
- 15| 1| }
- 16| |}
- 17| |
- 18| |pub mod baz {
- 19| 1| pub fn call_me() {
- 20| 1| super::foo::called();
- 21| 1| }
- 22| |}
-
diff --git a/tests/run-make/coverage-reports/expected_show_coverage.issue-93054.txt b/tests/run-make/coverage-reports/expected_show_coverage.issue-93054.txt
deleted file mode 100644
index a1655aded..000000000
--- a/tests/run-make/coverage-reports/expected_show_coverage.issue-93054.txt
+++ /dev/null
@@ -1,29 +0,0 @@
- 1| |// Regression test for #93054: Functions using uninhabited types often only have a single,
- 2| |// unreachable basic block which doesn't get instrumented. This should not cause llvm-cov to fail.
- 3| |// Since these kinds functions can't be invoked anyway, it's ok to not have coverage data for them.
- 4| |
- 5| |// compile-flags: --edition=2021
- 6| |
- 7| |enum Never { }
- 8| |
- 9| |impl Never {
- 10| | fn foo(self) {
- 11| | match self { }
- 12| | make().map(|never| match never { });
- 13| | }
- 14| |
- 15| | fn bar(&self) {
- 16| | match *self { }
- 17| | }
- 18| |}
- 19| |
- 20| 0|async fn foo2(never: Never) {
- 21| | match never { }
- 22| |}
- 23| |
- 24| 0|fn make() -> Option<Never> {
- 25| 0| None
- 26| 0|}
- 27| |
- 28| 1|fn main() { }
-
diff --git a/tests/run-make/coverage-reports/expected_show_coverage.lazy_boolean.txt b/tests/run-make/coverage-reports/expected_show_coverage.lazy_boolean.txt
deleted file mode 100644
index bd349df2f..000000000
--- a/tests/run-make/coverage-reports/expected_show_coverage.lazy_boolean.txt
+++ /dev/null
@@ -1,64 +0,0 @@
- 1| |#![allow(unused_assignments, unused_variables)]
- 2| |
- 3| 1|fn main() {
- 4| 1| // Initialize test constants in a way that cannot be determined at compile time, to ensure
- 5| 1| // rustc and LLVM cannot optimize out statements (or coverage counters) downstream from
- 6| 1| // dependent conditions.
- 7| 1| let is_true = std::env::args().len() == 1;
- 8| 1|
- 9| 1| let (mut a, mut b, mut c) = (0, 0, 0);
- 10| 1| if is_true {
- 11| 1| a = 1;
- 12| 1| b = 10;
- 13| 1| c = 100;
- 14| 1| }
- ^0
- 15| | let
- 16| 1| somebool
- 17| | =
- 18| 1| a < b
- 19| | ||
- 20| 0| b < c
- 21| | ;
- 22| | let
- 23| 1| somebool
- 24| | =
- 25| 1| b < a
- 26| | ||
- 27| 1| b < c
- 28| | ;
- 29| 1| let somebool = a < b && b < c;
- 30| 1| let somebool = b < a && b < c;
- ^0
- 31| |
- 32| | if
- 33| 1| !
- 34| 1| is_true
- 35| 0| {
- 36| 0| a = 2
- 37| 0| ;
- 38| 1| }
- 39| |
- 40| | if
- 41| 1| is_true
- 42| 1| {
- 43| 1| b = 30
- 44| 1| ;
- 45| 1| }
- 46| | else
- 47| 0| {
- 48| 0| c = 400
- 49| 0| ;
- 50| 0| }
- 51| |
- 52| 1| if !is_true {
- 53| 0| a = 2;
- 54| 1| }
- 55| |
- 56| 1| if is_true {
- 57| 1| b = 30;
- 58| 1| } else {
- 59| 0| c = 400;
- 60| 0| }
- 61| 1|}
-
diff --git a/tests/run-make/coverage-reports/expected_show_coverage.loop_break_value.txt b/tests/run-make/coverage-reports/expected_show_coverage.loop_break_value.txt
deleted file mode 100644
index 022fe4c59..000000000
--- a/tests/run-make/coverage-reports/expected_show_coverage.loop_break_value.txt
+++ /dev/null
@@ -1,14 +0,0 @@
- 1| |#![allow(unused_assignments, unused_variables)]
- 2| |
- 3| 1|fn main() {
- 4| 1| let result
- 5| 1| =
- 6| 1| loop
- 7| 1| {
- 8| 1| break
- 9| 1| 10
- 10| 1| ;
- 11| 1| }
- 12| 1| ;
- 13| 1|}
-
diff --git a/tests/run-make/coverage-reports/expected_show_coverage.loops_branches.txt b/tests/run-make/coverage-reports/expected_show_coverage.loops_branches.txt
deleted file mode 100644
index b7ad79a24..000000000
--- a/tests/run-make/coverage-reports/expected_show_coverage.loops_branches.txt
+++ /dev/null
@@ -1,68 +0,0 @@
- 1| |#![allow(unused_assignments, unused_variables, while_true)]
- 2| |
- 3| |// This test confirms that (1) unexecuted infinite loops are handled correctly by the
- 4| |// InstrumentCoverage MIR pass; and (2) Counter Expressions that subtract from zero can be dropped.
- 5| |
- 6| |struct DebugTest;
- 7| |
- 8| |impl std::fmt::Debug for DebugTest {
- 9| 1| fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
- 10| 1| if true {
- 11| 1| if false {
- 12| 0| while true {
- 13| 0| }
- 14| 1| }
- 15| 1| write!(f, "cool")?;
- ^0
- 16| 0| } else {
- 17| 0| }
- 18| |
- 19| 11| for i in 0..10 {
- ^10
- 20| 10| if true {
- 21| 10| if false {
- 22| 0| while true {}
- 23| 10| }
- 24| 10| write!(f, "cool")?;
- ^0
- 25| 0| } else {
- 26| 0| }
- 27| | }
- 28| 1| Ok(())
- 29| 1| }
- 30| |}
- 31| |
- 32| |struct DisplayTest;
- 33| |
- 34| |impl std::fmt::Display for DisplayTest {
- 35| 1| fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
- 36| 1| if false {
- 37| 0| } else {
- 38| 1| if false {
- 39| 0| while true {}
- 40| 1| }
- 41| 1| write!(f, "cool")?;
- ^0
- 42| | }
- 43| 11| for i in 0..10 {
- ^10
- 44| 10| if false {
- 45| 0| } else {
- 46| 10| if false {
- 47| 0| while true {}
- 48| 10| }
- 49| 10| write!(f, "cool")?;
- ^0
- 50| | }
- 51| | }
- 52| 1| Ok(())
- 53| 1| }
- 54| |}
- 55| |
- 56| 1|fn main() {
- 57| 1| let debug_test = DebugTest;
- 58| 1| println!("{:?}", debug_test);
- 59| 1| let display_test = DisplayTest;
- 60| 1| println!("{}", display_test);
- 61| 1|}
-
diff --git a/tests/run-make/coverage-reports/expected_show_coverage.match_or_pattern.txt b/tests/run-make/coverage-reports/expected_show_coverage.match_or_pattern.txt
deleted file mode 100644
index a0fccb24f..000000000
--- a/tests/run-make/coverage-reports/expected_show_coverage.match_or_pattern.txt
+++ /dev/null
@@ -1,50 +0,0 @@
- 1| |#![feature(or_patterns)]
- 2| |
- 3| 1|fn main() {
- 4| 1| // Initialize test constants in a way that cannot be determined at compile time, to ensure
- 5| 1| // rustc and LLVM cannot optimize out statements (or coverage counters) downstream from
- 6| 1| // dependent conditions.
- 7| 1| let is_true = std::env::args().len() == 1;
- 8| 1|
- 9| 1| let mut a: u8 = 0;
- 10| 1| let mut b: u8 = 0;
- 11| 1| if is_true {
- 12| 1| a = 2;
- 13| 1| b = 0;
- 14| 1| }
- ^0
- 15| 1| match (a, b) {
- 16| | // Or patterns generate MIR `SwitchInt` with multiple targets to the same `BasicBlock`.
- 17| | // This test confirms a fix for Issue #79569.
- 18| 0| (0 | 1, 2 | 3) => {}
- 19| 1| _ => {}
- 20| | }
- 21| 1| if is_true {
- 22| 1| a = 0;
- 23| 1| b = 0;
- 24| 1| }
- ^0
- 25| 1| match (a, b) {
- 26| 0| (0 | 1, 2 | 3) => {}
- 27| 1| _ => {}
- 28| | }
- 29| 1| if is_true {
- 30| 1| a = 2;
- 31| 1| b = 2;
- 32| 1| }
- ^0
- 33| 1| match (a, b) {
- 34| 0| (0 | 1, 2 | 3) => {}
- 35| 1| _ => {}
- 36| | }
- 37| 1| if is_true {
- 38| 1| a = 0;
- 39| 1| b = 2;
- 40| 1| }
- ^0
- 41| 1| match (a, b) {
- 42| 1| (0 | 1, 2 | 3) => {}
- 43| 0| _ => {}
- 44| | }
- 45| 1|}
-
diff --git a/tests/run-make/coverage-reports/expected_show_coverage.nested_loops.txt b/tests/run-make/coverage-reports/expected_show_coverage.nested_loops.txt
deleted file mode 100644
index 0dbd6bcf3..000000000
--- a/tests/run-make/coverage-reports/expected_show_coverage.nested_loops.txt
+++ /dev/null
@@ -1,26 +0,0 @@
- 1| 1|fn main() {
- 2| 1| let is_true = std::env::args().len() == 1;
- 3| 1| let mut countdown = 10;
- 4| |
- 5| 1| 'outer: while countdown > 0 {
- 6| 1| let mut a = 100;
- 7| 1| let mut b = 100;
- 8| 3| for _ in 0..50 {
- 9| 3| if a < 30 {
- 10| 0| break;
- 11| 3| }
- 12| 3| a -= 5;
- 13| 3| b -= 5;
- 14| 3| if b < 90 {
- 15| 1| a -= 10;
- 16| 1| if is_true {
- 17| 1| break 'outer;
- 18| 0| } else {
- 19| 0| a -= 2;
- 20| 0| }
- 21| 2| }
- 22| | }
- 23| 0| countdown -= 1;
- 24| | }
- 25| 1|}
-
diff --git a/tests/run-make/coverage-reports/expected_show_coverage.no_cov_crate.txt b/tests/run-make/coverage-reports/expected_show_coverage.no_cov_crate.txt
deleted file mode 100644
index 83a920413..000000000
--- a/tests/run-make/coverage-reports/expected_show_coverage.no_cov_crate.txt
+++ /dev/null
@@ -1,87 +0,0 @@
- 1| |// Enables `no_coverage` on the entire crate
- 2| |#![feature(no_coverage)]
- 3| |
- 4| |#[no_coverage]
- 5| |fn do_not_add_coverage_1() {
- 6| | println!("called but not covered");
- 7| |}
- 8| |
- 9| |fn do_not_add_coverage_2() {
- 10| | #![no_coverage]
- 11| | println!("called but not covered");
- 12| |}
- 13| |
- 14| |#[no_coverage]
- 15| |fn do_not_add_coverage_not_called() {
- 16| | println!("not called and not covered");
- 17| |}
- 18| |
- 19| 1|fn add_coverage_1() {
- 20| 1| println!("called and covered");
- 21| 1|}
- 22| |
- 23| 1|fn add_coverage_2() {
- 24| 1| println!("called and covered");
- 25| 1|}
- 26| |
- 27| 0|fn add_coverage_not_called() {
- 28| 0| println!("not called but covered");
- 29| 0|}
- 30| |
- 31| |// FIXME: These test-cases illustrate confusing results of nested functions.
- 32| |// See https://github.com/rust-lang/rust/issues/93319
- 33| |mod nested_fns {
- 34| | #[no_coverage]
- 35| | pub fn outer_not_covered(is_true: bool) {
- 36| 1| fn inner(is_true: bool) {
- 37| 1| if is_true {
- 38| 1| println!("called and covered");
- 39| 1| } else {
- 40| 0| println!("absolutely not covered");
- 41| 0| }
- 42| 1| }
- 43| | println!("called but not covered");
- 44| | inner(is_true);
- 45| | }
- 46| |
- 47| 1| pub fn outer(is_true: bool) {
- 48| 1| println!("called and covered");
- 49| 1| inner_not_covered(is_true);
- 50| 1|
- 51| 1| #[no_coverage]
- 52| 1| fn inner_not_covered(is_true: bool) {
- 53| 1| if is_true {
- 54| 1| println!("called but not covered");
- 55| 1| } else {
- 56| 1| println!("absolutely not covered");
- 57| 1| }
- 58| 1| }
- 59| 1| }
- 60| |
- 61| 1| pub fn outer_both_covered(is_true: bool) {
- 62| 1| println!("called and covered");
- 63| 1| inner(is_true);
- 64| 1|
- 65| 1| fn inner(is_true: bool) {
- 66| 1| if is_true {
- 67| 1| println!("called and covered");
- 68| 1| } else {
- 69| 0| println!("absolutely not covered");
- 70| 0| }
- 71| 1| }
- 72| 1| }
- 73| |}
- 74| |
- 75| 1|fn main() {
- 76| 1| let is_true = std::env::args().len() == 1;
- 77| 1|
- 78| 1| do_not_add_coverage_1();
- 79| 1| do_not_add_coverage_2();
- 80| 1| add_coverage_1();
- 81| 1| add_coverage_2();
- 82| 1|
- 83| 1| nested_fns::outer_not_covered(is_true);
- 84| 1| nested_fns::outer(is_true);
- 85| 1| nested_fns::outer_both_covered(is_true);
- 86| 1|}
-
diff --git a/tests/run-make/coverage-reports/expected_show_coverage.overflow.txt b/tests/run-make/coverage-reports/expected_show_coverage.overflow.txt
deleted file mode 100644
index 25e822bff..000000000
--- a/tests/run-make/coverage-reports/expected_show_coverage.overflow.txt
+++ /dev/null
@@ -1,64 +0,0 @@
- 1| |#![allow(unused_assignments)]
- 2| |// expect-exit-status-101
- 3| |
- 4| 4|fn might_overflow(to_add: u32) -> u32 {
- 5| 4| if to_add > 5 {
- 6| 1| println!("this will probably overflow");
- 7| 3| }
- 8| 4| let add_to = u32::MAX - 5;
- 9| 4| println!("does {} + {} overflow?", add_to, to_add);
- 10| 4| let result = to_add + add_to;
- 11| 4| println!("continuing after overflow check");
- 12| 4| result
- 13| 4|}
- 14| |
- 15| 1|fn main() -> Result<(),u8> {
- 16| 1| let mut countdown = 10;
- 17| 11| while countdown > 0 {
- 18| 11| if countdown == 1 {
- 19| 1| let result = might_overflow(10);
- 20| 1| println!("Result: {}", result);
- 21| 10| } else if countdown < 5 {
- 22| 3| let result = might_overflow(1);
- 23| 3| println!("Result: {}", result);
- 24| 6| }
- 25| 10| countdown -= 1;
- 26| | }
- 27| 0| Ok(())
- 28| 0|}
- 29| |
- 30| |// Notes:
- 31| |// 1. Compare this program and its coverage results to those of the very similar test `assert.rs`,
- 32| |// and similar tests `panic_unwind.rs`, abort.rs` and `try_error_result.rs`.
- 33| |// 2. This test confirms the coverage generated when a program passes or fails a
- 34| |// compiler-generated `TerminatorKind::Assert` (based on an overflow check, in this case).
- 35| |// 3. Similar to how the coverage instrumentation handles `TerminatorKind::Call`,
- 36| |// compiler-generated assertion failures are assumed to be a symptom of a program bug, not
- 37| |// expected behavior. To simplify the coverage graphs and keep instrumented programs as
- 38| |// small and fast as possible, `Assert` terminators are assumed to always succeed, and
- 39| |// therefore are considered "non-branching" terminators. So, an `Assert` terminator does not
- 40| |// get its own coverage counter.
- 41| |// 4. After an unhandled panic or failed Assert, coverage results may not always be intuitive.
- 42| |// In this test, the final count for the statements after the `if` block in `might_overflow()`
- 43| |// is 4, even though the lines after `to_add + add_to` were executed only 3 times. Depending
- 44| |// on the MIR graph and the structure of the code, this count could have been 3 (which might
- 45| |// have been valid for the overflowed add `+`, but should have been 4 for the lines before
- 46| |// the overflow. The reason for this potential uncertainty is, a `CounterKind` is incremented
- 47| |// via StatementKind::Counter at the end of the block, but (as in the case in this test),
- 48| |// a CounterKind::Expression is always evaluated. In this case, the expression was based on
- 49| |// a `Counter` incremented as part of the evaluation of the `if` expression, which was
- 50| |// executed, and counted, 4 times, before reaching the overflow add.
- 51| |
- 52| |// If the program did not overflow, the coverage for `might_overflow()` would look like this:
- 53| |//
- 54| |// 4| |fn might_overflow(to_add: u32) -> u32 {
- 55| |// 5| 4| if to_add > 5 {
- 56| |// 6| 0| println!("this will probably overflow");
- 57| |// 7| 4| }
- 58| |// 8| 4| let add_to = u32::MAX - 5;
- 59| |// 9| 4| println!("does {} + {} overflow?", add_to, to_add);
- 60| |// 10| 4| let result = to_add + add_to;
- 61| |// 11| 4| println!("continuing after overflow check");
- 62| |// 12| 4| result
- 63| |// 13| 4|}
-
diff --git a/tests/run-make/coverage-reports/expected_show_coverage.panic_unwind.txt b/tests/run-make/coverage-reports/expected_show_coverage.panic_unwind.txt
deleted file mode 100644
index 114507dc9..000000000
--- a/tests/run-make/coverage-reports/expected_show_coverage.panic_unwind.txt
+++ /dev/null
@@ -1,32 +0,0 @@
- 1| |#![allow(unused_assignments)]
- 2| |// expect-exit-status-101
- 3| |
- 4| 4|fn might_panic(should_panic: bool) {
- 5| 4| if should_panic {
- 6| 1| println!("panicking...");
- 7| 1| panic!("panics");
- 8| 3| } else {
- 9| 3| println!("Don't Panic");
- 10| 3| }
- 11| 3|}
- 12| |
- 13| 1|fn main() -> Result<(), u8> {
- 14| 1| let mut countdown = 10;
- 15| 11| while countdown > 0 {
- 16| 11| if countdown == 1 {
- 17| 1| might_panic(true);
- 18| 10| } else if countdown < 5 {
- 19| 3| might_panic(false);
- 20| 6| }
- 21| 10| countdown -= 1;
- 22| | }
- 23| 0| Ok(())
- 24| 0|}
- 25| |
- 26| |// Notes:
- 27| |// 1. Compare this program and its coverage results to those of the similar tests `abort.rs` and
- 28| |// `try_error_result.rs`.
- 29| |// 2. Since the `panic_unwind.rs` test is allowed to unwind, it is also allowed to execute the
- 30| |// normal program exit cleanup, including writing out the current values of the coverage
- 31| |// counters.
-
diff --git a/tests/run-make/coverage-reports/expected_show_coverage.partial_eq.txt b/tests/run-make/coverage-reports/expected_show_coverage.partial_eq.txt
deleted file mode 100644
index a77175af6..000000000
--- a/tests/run-make/coverage-reports/expected_show_coverage.partial_eq.txt
+++ /dev/null
@@ -1,48 +0,0 @@
- 1| |// This test confirms an earlier problem was resolved, supporting the MIR graph generated by the
- 2| |// structure of this test.
- 3| |
- 4| 2|#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord)]
- ^0 ^0 ^0 ^1 ^1 ^0^0
- 5| |pub struct Version {
- 6| | major: usize,
- 7| | minor: usize,
- 8| | patch: usize,
- 9| |}
- 10| |
- 11| |impl Version {
- 12| 2| pub fn new(major: usize, minor: usize, patch: usize) -> Self {
- 13| 2| Self {
- 14| 2| major,
- 15| 2| minor,
- 16| 2| patch,
- 17| 2| }
- 18| 2| }
- 19| |}
- 20| |
- 21| 1|fn main() {
- 22| 1| let version_3_2_1 = Version::new(3, 2, 1);
- 23| 1| let version_3_3_0 = Version::new(3, 3, 0);
- 24| 1|
- 25| 1| println!("{:?} < {:?} = {}", version_3_2_1, version_3_3_0, version_3_2_1 < version_3_3_0);
- 26| 1|}
- 27| |
- 28| |/*
- 29| |
- 30| |This test verifies a bug was fixed that otherwise generated this error:
- 31| |
- 32| |thread 'rustc' panicked at 'No counters provided the source_hash for function:
- 33| | Instance {
- 34| | def: Item(WithOptConstParam {
- 35| | did: DefId(0:101 ~ autocfg[c44a]::version::{impl#2}::partial_cmp),
- 36| | const_param_did: None
- 37| | }),
- 38| | substs: []
- 39| | }'
- 40| |The `PartialOrd` derived by `Version` happened to generate a MIR that generated coverage
- 41| |without a code region associated with any `Counter`. Code regions were associated with at least
- 42| |one expression, which is allowed, but the `function_source_hash` was only passed to the codegen
- 43| |(coverage mapgen) phase from a `Counter`s code region. A new method was added to pass the
- 44| |`function_source_hash` without a code region, if necessary.
- 45| |
- 46| |*/
-
diff --git a/tests/run-make/coverage-reports/expected_show_coverage.simple_loop.txt b/tests/run-make/coverage-reports/expected_show_coverage.simple_loop.txt
deleted file mode 100644
index feb83bad6..000000000
--- a/tests/run-make/coverage-reports/expected_show_coverage.simple_loop.txt
+++ /dev/null
@@ -1,37 +0,0 @@
- 1| |#![allow(unused_assignments)]
- 2| |
- 3| 1|fn main() {
- 4| 1| // Initialize test constants in a way that cannot be determined at compile time, to ensure
- 5| 1| // rustc and LLVM cannot optimize out statements (or coverage counters) downstream from
- 6| 1| // dependent conditions.
- 7| 1| let is_true = std::env::args().len() == 1;
- 8| 1|
- 9| 1| let mut countdown = 0;
- 10| 1|
- 11| 1| if
- 12| 1| is_true
- 13| 1| {
- 14| 1| countdown
- 15| 1| =
- 16| 1| 10
- 17| 1| ;
- 18| 1| }
- ^0
- 19| |
- 20| | loop
- 21| | {
- 22| | if
- 23| 11| countdown
- 24| 11| ==
- 25| 11| 0
- 26| | {
- 27| 1| break
- 28| | ;
- 29| 10| }
- 30| 10| countdown
- 31| 10| -=
- 32| 10| 1
- 33| | ;
- 34| | }
- 35| 1|}
-
diff --git a/tests/run-make/coverage-reports/expected_show_coverage.simple_match.txt b/tests/run-make/coverage-reports/expected_show_coverage.simple_match.txt
deleted file mode 100644
index b92982131..000000000
--- a/tests/run-make/coverage-reports/expected_show_coverage.simple_match.txt
+++ /dev/null
@@ -1,45 +0,0 @@
- 1| |#![allow(unused_assignments, unused_variables)]
- 2| |
- 3| 1|fn main() {
- 4| 1| // Initialize test constants in a way that cannot be determined at compile time, to ensure
- 5| 1| // rustc and LLVM cannot optimize out statements (or coverage counters) downstream from
- 6| 1| // dependent conditions.
- 7| 1| let is_true = std::env::args().len() == 1;
- 8| 1|
- 9| 1| let mut countdown = 1;
- 10| 1| if is_true {
- 11| 1| countdown = 0;
- 12| 1| }
- ^0
- 13| |
- 14| | for
- 15| | _
- 16| | in
- 17| 3| 0..2
- 18| | {
- 19| | let z
- 20| | ;
- 21| | match
- 22| 2| countdown
- 23| | {
- 24| 1| x
- 25| | if
- 26| 2| x
- 27| 2| <
- 28| 2| 1
- 29| | =>
- 30| 1| {
- 31| 1| z = countdown
- 32| 1| ;
- 33| 1| let y = countdown
- 34| 1| ;
- 35| 1| countdown = 10
- 36| 1| ;
- 37| 1| }
- 38| | _
- 39| | =>
- 40| 1| {}
- 41| | }
- 42| | }
- 43| 1|}
-
diff --git a/tests/run-make/coverage-reports/expected_show_coverage.sort_groups.txt b/tests/run-make/coverage-reports/expected_show_coverage.sort_groups.txt
deleted file mode 100644
index 81468cb35..000000000
--- a/tests/run-make/coverage-reports/expected_show_coverage.sort_groups.txt
+++ /dev/null
@@ -1,49 +0,0 @@
- 1| |// compile-flags: --edition=2021
- 2| |
- 3| |// Demonstrate that `sort_subviews.py` can sort instantiation groups into a
- 4| |// predictable order, while preserving their heterogeneous contents.
- 5| |
- 6| 1|fn main() {
- 7| 1| let cond = std::env::args().len() > 1;
- 8| 1| generic_fn::<()>(cond);
- 9| 1| generic_fn::<&'static str>(!cond);
- 10| 1| if false {
- 11| 0| generic_fn::<char>(cond);
- 12| 1| }
- 13| 1| generic_fn::<i32>(cond);
- 14| 1| other_fn();
- 15| 1|}
- 16| |
- 17| 3|fn generic_fn<T>(cond: bool) {
- 18| 3| if cond {
- 19| 1| println!("{}", std::any::type_name::<T>());
- 20| 2| }
- 21| 3|}
- ------------------
- | Unexecuted instantiation: sort_groups::generic_fn::<char>
- ------------------
- | sort_groups::generic_fn::<&str>:
- | 17| 1|fn generic_fn<T>(cond: bool) {
- | 18| 1| if cond {
- | 19| 1| println!("{}", std::any::type_name::<T>());
- | 20| 1| }
- | ^0
- | 21| 1|}
- ------------------
- | sort_groups::generic_fn::<()>:
- | 17| 1|fn generic_fn<T>(cond: bool) {
- | 18| 1| if cond {
- | 19| 0| println!("{}", std::any::type_name::<T>());
- | 20| 1| }
- | 21| 1|}
- ------------------
- | sort_groups::generic_fn::<i32>:
- | 17| 1|fn generic_fn<T>(cond: bool) {
- | 18| 1| if cond {
- | 19| 0| println!("{}", std::any::type_name::<T>());
- | 20| 1| }
- | 21| 1|}
- ------------------
- 22| |
- 23| 1|fn other_fn() {}
-
diff --git a/tests/run-make/coverage-reports/expected_show_coverage.test_harness.txt b/tests/run-make/coverage-reports/expected_show_coverage.test_harness.txt
deleted file mode 100644
index 93bd1cfcb..000000000
--- a/tests/run-make/coverage-reports/expected_show_coverage.test_harness.txt
+++ /dev/null
@@ -1,11 +0,0 @@
- 1| |// Verify that the entry point injected by the test harness doesn't cause
- 2| |// weird artifacts in the coverage report (e.g. issue #10749).
- 3| |
- 4| |// compile-flags: --test
- 5| |
- 6| |#[allow(dead_code)]
- 7| 0|fn unused() {}
- 8| |
- 9| 1|#[test]
- 10| 1|fn my_test() {}
-
diff --git a/tests/run-make/coverage-reports/expected_show_coverage.tight_inf_loop.txt b/tests/run-make/coverage-reports/expected_show_coverage.tight_inf_loop.txt
deleted file mode 100644
index 2d4c57f45..000000000
--- a/tests/run-make/coverage-reports/expected_show_coverage.tight_inf_loop.txt
+++ /dev/null
@@ -1,6 +0,0 @@
- 1| 1|fn main() {
- 2| 1| if false {
- 3| 0| loop {}
- 4| 1| }
- 5| 1|}
-
diff --git a/tests/run-make/coverage-reports/expected_show_coverage.try_error_result.txt b/tests/run-make/coverage-reports/expected_show_coverage.try_error_result.txt
deleted file mode 100644
index 0ad0180b7..000000000
--- a/tests/run-make/coverage-reports/expected_show_coverage.try_error_result.txt
+++ /dev/null
@@ -1,125 +0,0 @@
- 1| |#![allow(unused_assignments)]
- 2| |// expect-exit-status-1
- 3| |
- 4| 6|fn call(return_error: bool) -> Result<(),()> {
- 5| 6| if return_error {
- 6| 1| Err(())
- 7| | } else {
- 8| 5| Ok(())
- 9| | }
- 10| 6|}
- 11| |
- 12| 1|fn test1() -> Result<(),()> {
- 13| 1| let mut
- 14| 1| countdown = 10
- 15| | ;
- 16| | for
- 17| | _
- 18| | in
- 19| 6| 0..10
- 20| | {
- 21| 6| countdown
- 22| 6| -= 1
- 23| 6| ;
- 24| 6| if
- 25| 6| countdown < 5
- 26| | {
- 27| 1| call(/*return_error=*/ true)?;
- 28| 0| call(/*return_error=*/ false)?;
- 29| | }
- 30| | else
- 31| | {
- 32| 5| call(/*return_error=*/ false)?;
- ^0
- 33| | }
- 34| | }
- 35| 0| Ok(())
- 36| 1|}
- 37| |
- 38| |struct Thing1;
- 39| |impl Thing1 {
- 40| 18| fn get_thing_2(&self, return_error: bool) -> Result<Thing2,()> {
- 41| 18| if return_error {
- 42| 1| Err(())
- 43| | } else {
- 44| 17| Ok(Thing2{})
- 45| | }
- 46| 18| }
- 47| |}
- 48| |
- 49| |struct Thing2;
- 50| |impl Thing2 {
- 51| 17| fn call(&self, return_error: bool) -> Result<u32,()> {
- 52| 17| if return_error {
- 53| 2| Err(())
- 54| | } else {
- 55| 15| Ok(57)
- 56| | }
- 57| 17| }
- 58| |}
- 59| |
- 60| 1|fn test2() -> Result<(),()> {
- 61| 1| let thing1 = Thing1{};
- 62| 1| let mut
- 63| 1| countdown = 10
- 64| | ;
- 65| | for
- 66| | _
- 67| | in
- 68| 6| 0..10
- 69| | {
- 70| 6| countdown
- 71| 6| -= 1
- 72| 6| ;
- 73| 6| if
- 74| 6| countdown < 5
- 75| | {
- 76| 1| thing1.get_thing_2(/*err=*/ false)?.call(/*err=*/ true).expect_err("call should fail");
- ^0
- 77| 1| thing1
- 78| 1| .
- 79| 1| get_thing_2(/*return_error=*/ false)
- 80| 0| ?
- 81| | .
- 82| 1| call(/*return_error=*/ true)
- 83| 1| .
- 84| 1| expect_err(
- 85| 1| "call should fail"
- 86| 1| );
- 87| 1| let val = thing1.get_thing_2(/*return_error=*/ true)?.call(/*return_error=*/ true)?;
- ^0 ^0 ^0
- 88| 0| assert_eq!(val, 57);
- 89| 0| let val = thing1.get_thing_2(/*return_error=*/ true)?.call(/*return_error=*/ false)?;
- 90| 0| assert_eq!(val, 57);
- 91| | }
- 92| | else
- 93| | {
- 94| 5| let val = thing1.get_thing_2(/*return_error=*/ false)?.call(/*return_error=*/ false)?;
- ^0 ^0
- 95| 5| assert_eq!(val, 57);
- 96| 5| let val = thing1
- 97| 5| .get_thing_2(/*return_error=*/ false)?
- ^0
- 98| 5| .call(/*return_error=*/ false)?;
- ^0
- 99| 5| assert_eq!(val, 57);
- 100| 5| let val = thing1
- 101| 5| .get_thing_2(/*return_error=*/ false)
- 102| 0| ?
- 103| 5| .call(/*return_error=*/ false)
- 104| 0| ?
- 105| | ;
- 106| 5| assert_eq!(val, 57);
- 107| | }
- 108| | }
- 109| 0| Ok(())
- 110| 1|}
- 111| |
- 112| 1|fn main() -> Result<(),()> {
- 113| 1| test1().expect_err("test1 should fail");
- 114| 1| test2()
- 115| 1| ?
- 116| | ;
- 117| 0| Ok(())
- 118| 1|}
-
diff --git a/tests/run-make/coverage-reports/expected_show_coverage.unused.txt b/tests/run-make/coverage-reports/expected_show_coverage.unused.txt
deleted file mode 100644
index 15fcf21c0..000000000
--- a/tests/run-make/coverage-reports/expected_show_coverage.unused.txt
+++ /dev/null
@@ -1,62 +0,0 @@
- 1| 2|fn foo<T>(x: T) {
- 2| 2| let mut i = 0;
- 3| 22| while i < 10 {
- 4| 20| i != 0 || i != 0;
- ^2
- 5| 20| i += 1;
- 6| | }
- 7| 2|}
- ------------------
- | unused::foo::<f32>:
- | 1| 1|fn foo<T>(x: T) {
- | 2| 1| let mut i = 0;
- | 3| 11| while i < 10 {
- | 4| 10| i != 0 || i != 0;
- | ^1
- | 5| 10| i += 1;
- | 6| | }
- | 7| 1|}
- ------------------
- | unused::foo::<u32>:
- | 1| 1|fn foo<T>(x: T) {
- | 2| 1| let mut i = 0;
- | 3| 11| while i < 10 {
- | 4| 10| i != 0 || i != 0;
- | ^1
- | 5| 10| i += 1;
- | 6| | }
- | 7| 1|}
- ------------------
- 8| |
- 9| 0|fn unused_template_func<T>(x: T) {
- 10| 0| let mut i = 0;
- 11| 0| while i < 10 {
- 12| 0| i != 0 || i != 0;
- 13| 0| i += 1;
- 14| | }
- 15| 0|}
- 16| |
- 17| 0|fn unused_func(mut a: u32) {
- 18| 0| if a != 0 {
- 19| 0| a += 1;
- 20| 0| }
- 21| 0|}
- 22| |
- 23| 0|fn unused_func2(mut a: u32) {
- 24| 0| if a != 0 {
- 25| 0| a += 1;
- 26| 0| }
- 27| 0|}
- 28| |
- 29| 0|fn unused_func3(mut a: u32) {
- 30| 0| if a != 0 {
- 31| 0| a += 1;
- 32| 0| }
- 33| 0|}
- 34| |
- 35| 1|fn main() -> Result<(), u8> {
- 36| 1| foo::<u32>(0);
- 37| 1| foo::<f32>(0.0);
- 38| 1| Ok(())
- 39| 1|}
-
diff --git a/tests/run-make/coverage-reports/expected_show_coverage.unused_mod.txt b/tests/run-make/coverage-reports/expected_show_coverage.unused_mod.txt
deleted file mode 100644
index 82d6fccc2..000000000
--- a/tests/run-make/coverage-reports/expected_show_coverage.unused_mod.txt
+++ /dev/null
@@ -1,4 +0,0 @@
- 1| 0|pub fn never_called_function() {
- 2| 0| println!("I am never called");
- 3| 0|}
-
diff --git a/tests/run-make/coverage-reports/expected_show_coverage.uses_crate.txt b/tests/run-make/coverage-reports/expected_show_coverage.uses_crate.txt
deleted file mode 100644
index 412f4a93b..000000000
--- a/tests/run-make/coverage-reports/expected_show_coverage.uses_crate.txt
+++ /dev/null
@@ -1,148 +0,0 @@
- 1| |#![allow(unused_assignments, unused_variables)]
- 2| |// compile-flags: -C opt-level=3 # validates coverage now works with optimizations
- 3| |use std::fmt::Debug;
- 4| |
- 5| 1|pub fn used_function() {
- 6| 1| // Initialize test constants in a way that cannot be determined at compile time, to ensure
- 7| 1| // rustc and LLVM cannot optimize out statements (or coverage counters) downstream from
- 8| 1| // dependent conditions.
- 9| 1| let is_true = std::env::args().len() == 1;
- 10| 1| let mut countdown = 0;
- 11| 1| if is_true {
- 12| 1| countdown = 10;
- 13| 1| }
- ^0
- 14| 1| use_this_lib_crate();
- 15| 1|}
- 16| |
- 17| 2|pub fn used_only_from_bin_crate_generic_function<T: Debug>(arg: T) {
- 18| 2| println!("used_only_from_bin_crate_generic_function with {:?}", arg);
- 19| 2|}
- ------------------
- | Unexecuted instantiation: used_crate::used_only_from_bin_crate_generic_function::<_>
- ------------------
- | used_crate::used_only_from_bin_crate_generic_function::<&alloc::vec::Vec<i32>>:
- | 17| 1|pub fn used_only_from_bin_crate_generic_function<T: Debug>(arg: T) {
- | 18| 1| println!("used_only_from_bin_crate_generic_function with {:?}", arg);
- | 19| 1|}
- ------------------
- | used_crate::used_only_from_bin_crate_generic_function::<&str>:
- | 17| 1|pub fn used_only_from_bin_crate_generic_function<T: Debug>(arg: T) {
- | 18| 1| println!("used_only_from_bin_crate_generic_function with {:?}", arg);
- | 19| 1|}
- ------------------
- 20| |// Expect for above function: `Unexecuted instantiation` (see below)
- 21| 2|pub fn used_only_from_this_lib_crate_generic_function<T: Debug>(arg: T) {
- 22| 2| println!("used_only_from_this_lib_crate_generic_function with {:?}", arg);
- 23| 2|}
- ------------------
- | used_crate::used_only_from_this_lib_crate_generic_function::<&str>:
- | 21| 1|pub fn used_only_from_this_lib_crate_generic_function<T: Debug>(arg: T) {
- | 22| 1| println!("used_only_from_this_lib_crate_generic_function with {:?}", arg);
- | 23| 1|}
- ------------------
- | used_crate::used_only_from_this_lib_crate_generic_function::<alloc::vec::Vec<i32>>:
- | 21| 1|pub fn used_only_from_this_lib_crate_generic_function<T: Debug>(arg: T) {
- | 22| 1| println!("used_only_from_this_lib_crate_generic_function with {:?}", arg);
- | 23| 1|}
- ------------------
- 24| |
- 25| 2|pub fn used_from_bin_crate_and_lib_crate_generic_function<T: Debug>(arg: T) {
- 26| 2| println!("used_from_bin_crate_and_lib_crate_generic_function with {:?}", arg);
- 27| 2|}
- ------------------
- | used_crate::used_from_bin_crate_and_lib_crate_generic_function::<&str>:
- | 25| 1|pub fn used_from_bin_crate_and_lib_crate_generic_function<T: Debug>(arg: T) {
- | 26| 1| println!("used_from_bin_crate_and_lib_crate_generic_function with {:?}", arg);
- | 27| 1|}
- ------------------
- | used_crate::used_from_bin_crate_and_lib_crate_generic_function::<alloc::vec::Vec<i32>>:
- | 25| 1|pub fn used_from_bin_crate_and_lib_crate_generic_function<T: Debug>(arg: T) {
- | 26| 1| println!("used_from_bin_crate_and_lib_crate_generic_function with {:?}", arg);
- | 27| 1|}
- ------------------
- 28| |
- 29| 2|pub fn used_with_same_type_from_bin_crate_and_lib_crate_generic_function<T: Debug>(arg: T) {
- 30| 2| println!("used_with_same_type_from_bin_crate_and_lib_crate_generic_function with {:?}", arg);
- 31| 2|}
- ------------------
- | used_crate::used_with_same_type_from_bin_crate_and_lib_crate_generic_function::<&str>:
- | 29| 1|pub fn used_with_same_type_from_bin_crate_and_lib_crate_generic_function<T: Debug>(arg: T) {
- | 30| 1| println!("used_with_same_type_from_bin_crate_and_lib_crate_generic_function with {:?}", arg);
- | 31| 1|}
- ------------------
- | used_crate::used_with_same_type_from_bin_crate_and_lib_crate_generic_function::<&str>:
- | 29| 1|pub fn used_with_same_type_from_bin_crate_and_lib_crate_generic_function<T: Debug>(arg: T) {
- | 30| 1| println!("used_with_same_type_from_bin_crate_and_lib_crate_generic_function with {:?}", arg);
- | 31| 1|}
- ------------------
- 32| |
- 33| 0|pub fn unused_generic_function<T: Debug>(arg: T) {
- 34| 0| println!("unused_generic_function with {:?}", arg);
- 35| 0|}
- 36| |
- 37| 0|pub fn unused_function() {
- 38| 0| let is_true = std::env::args().len() == 1;
- 39| 0| let mut countdown = 2;
- 40| 0| if !is_true {
- 41| 0| countdown = 20;
- 42| 0| }
- 43| 0|}
- 44| |
- 45| 0|fn unused_private_function() {
- 46| 0| let is_true = std::env::args().len() == 1;
- 47| 0| let mut countdown = 2;
- 48| 0| if !is_true {
- 49| 0| countdown = 20;
- 50| 0| }
- 51| 0|}
- 52| |
- 53| 1|fn use_this_lib_crate() {
- 54| 1| used_from_bin_crate_and_lib_crate_generic_function("used from library used_crate.rs");
- 55| 1| used_with_same_type_from_bin_crate_and_lib_crate_generic_function(
- 56| 1| "used from library used_crate.rs",
- 57| 1| );
- 58| 1| let some_vec = vec![5, 6, 7, 8];
- 59| 1| used_only_from_this_lib_crate_generic_function(some_vec);
- 60| 1| used_only_from_this_lib_crate_generic_function("used ONLY from library used_crate.rs");
- 61| 1|}
- 62| |
- 63| |// FIXME(#79651): "Unexecuted instantiation" errors appear in coverage results,
- 64| |// for example:
- 65| |//
- 66| |// | Unexecuted instantiation: used_crate::used_only_from_bin_crate_generic_function::<_>
- 67| |//
- 68| |// These notices appear when `llvm-cov` shows instantiations. This may be a
- 69| |// default option, but it can be suppressed with:
- 70| |//
- 71| |// ```shell
- 72| |// $ `llvm-cov show --show-instantiations=0 ...`
- 73| |// ```
- 74| |//
- 75| |// The notice is triggered because the function is unused by the library itself,
- 76| |// and when the library is compiled, a synthetic function is generated, so
- 77| |// unused function coverage can be reported. Coverage can be skipped for unused
- 78| |// generic functions with:
- 79| |//
- 80| |// ```shell
- 81| |// $ `rustc -Zunstable-options -C instrument-coverage=except-unused-generics ...`
- 82| |// ```
- 83| |//
- 84| |// Even though this function is used by `uses_crate.rs` (and
- 85| |// counted), with substitutions for `T`, those instantiations are only generated
- 86| |// when the generic function is actually used (from the binary, not from this
- 87| |// library crate). So the test result shows coverage for all instantiated
- 88| |// versions and their generic type substitutions, plus the `Unexecuted
- 89| |// instantiation` message for the non-substituted version. This is valid, but
- 90| |// unfortunately a little confusing.
- 91| |//
- 92| |// The library crate has its own coverage map, and the only way to show unused
- 93| |// coverage of a generic function is to include the generic function in the
- 94| |// coverage map, marked as an "unused function". If the library were used by
- 95| |// another binary that never used this generic function, then it would be valid
- 96| |// to show the unused generic, with unknown substitution (`_`).
- 97| |//
- 98| |// The alternative is to exclude all generics from being included in the "unused
- 99| |// functions" list, which would then omit coverage results for
- 100| |// `unused_generic_function<T>()`, below.
-
diff --git a/tests/run-make/coverage-reports/expected_show_coverage.uses_inline_crate.txt b/tests/run-make/coverage-reports/expected_show_coverage.uses_inline_crate.txt
deleted file mode 100644
index 66ca9e80a..000000000
--- a/tests/run-make/coverage-reports/expected_show_coverage.uses_inline_crate.txt
+++ /dev/null
@@ -1,139 +0,0 @@
- 1| |#![allow(unused_assignments, unused_variables)]
- 2| |
- 3| |// compile-flags: -C opt-level=3 # validates coverage now works with optimizations
- 4| |
- 5| |use std::fmt::Debug;
- 6| |
- 7| 1|pub fn used_function() {
- 8| 1| // Initialize test constants in a way that cannot be determined at compile time, to ensure
- 9| 1| // rustc and LLVM cannot optimize out statements (or coverage counters) downstream from
- 10| 1| // dependent conditions.
- 11| 1| let is_true = std::env::args().len() == 1;
- 12| 1| let mut countdown = 0;
- 13| 1| if is_true {
- 14| 1| countdown = 10;
- 15| 1| }
- ^0
- 16| 1| use_this_lib_crate();
- 17| 1|}
- 18| |
- 19| |#[inline(always)]
- 20| 1|pub fn used_inline_function() {
- 21| 1| // Initialize test constants in a way that cannot be determined at compile time, to ensure
- 22| 1| // rustc and LLVM cannot optimize out statements (or coverage counters) downstream from
- 23| 1| // dependent conditions.
- 24| 1| let is_true = std::env::args().len() == 1;
- 25| 1| let mut countdown = 0;
- 26| 1| if is_true {
- 27| 1| countdown = 10;
- 28| 1| }
- ^0
- 29| 1| use_this_lib_crate();
- 30| 1|}
- 31| |
- 32| |
- 33| |
- 34| |
- 35| |
- 36| |
- 37| |
- 38| |#[inline(always)]
- 39| 2|pub fn used_only_from_bin_crate_generic_function<T: Debug>(arg: T) {
- 40| 2| println!("used_only_from_bin_crate_generic_function with {:?}", arg);
- 41| 2|}
- ------------------
- | Unexecuted instantiation: used_inline_crate::used_only_from_bin_crate_generic_function::<_>
- ------------------
- | used_inline_crate::used_only_from_bin_crate_generic_function::<&alloc::vec::Vec<i32>>:
- | 39| 1|pub fn used_only_from_bin_crate_generic_function<T: Debug>(arg: T) {
- | 40| 1| println!("used_only_from_bin_crate_generic_function with {:?}", arg);
- | 41| 1|}
- ------------------
- | used_inline_crate::used_only_from_bin_crate_generic_function::<&str>:
- | 39| 1|pub fn used_only_from_bin_crate_generic_function<T: Debug>(arg: T) {
- | 40| 1| println!("used_only_from_bin_crate_generic_function with {:?}", arg);
- | 41| 1|}
- ------------------
- 42| |// Expect for above function: `Unexecuted instantiation` (see notes in `used_crate.rs`)
- 43| |
- 44| |#[inline(always)]
- 45| 4|pub fn used_only_from_this_lib_crate_generic_function<T: Debug>(arg: T) {
- 46| 4| println!("used_only_from_this_lib_crate_generic_function with {:?}", arg);
- 47| 4|}
- ------------------
- | used_inline_crate::used_only_from_this_lib_crate_generic_function::<&str>:
- | 45| 2|pub fn used_only_from_this_lib_crate_generic_function<T: Debug>(arg: T) {
- | 46| 2| println!("used_only_from_this_lib_crate_generic_function with {:?}", arg);
- | 47| 2|}
- ------------------
- | used_inline_crate::used_only_from_this_lib_crate_generic_function::<alloc::vec::Vec<i32>>:
- | 45| 2|pub fn used_only_from_this_lib_crate_generic_function<T: Debug>(arg: T) {
- | 46| 2| println!("used_only_from_this_lib_crate_generic_function with {:?}", arg);
- | 47| 2|}
- ------------------
- 48| |
- 49| |#[inline(always)]
- 50| 3|pub fn used_from_bin_crate_and_lib_crate_generic_function<T: Debug>(arg: T) {
- 51| 3| println!("used_from_bin_crate_and_lib_crate_generic_function with {:?}", arg);
- 52| 3|}
- ------------------
- | used_inline_crate::used_from_bin_crate_and_lib_crate_generic_function::<&str>:
- | 50| 2|pub fn used_from_bin_crate_and_lib_crate_generic_function<T: Debug>(arg: T) {
- | 51| 2| println!("used_from_bin_crate_and_lib_crate_generic_function with {:?}", arg);
- | 52| 2|}
- ------------------
- | used_inline_crate::used_from_bin_crate_and_lib_crate_generic_function::<alloc::vec::Vec<i32>>:
- | 50| 1|pub fn used_from_bin_crate_and_lib_crate_generic_function<T: Debug>(arg: T) {
- | 51| 1| println!("used_from_bin_crate_and_lib_crate_generic_function with {:?}", arg);
- | 52| 1|}
- ------------------
- 53| |
- 54| |#[inline(always)]
- 55| 3|pub fn used_with_same_type_from_bin_crate_and_lib_crate_generic_function<T: Debug>(arg: T) {
- 56| 3| println!("used_with_same_type_from_bin_crate_and_lib_crate_generic_function with {:?}", arg);
- 57| 3|}
- ------------------
- | used_inline_crate::used_with_same_type_from_bin_crate_and_lib_crate_generic_function::<&str>:
- | 55| 1|pub fn used_with_same_type_from_bin_crate_and_lib_crate_generic_function<T: Debug>(arg: T) {
- | 56| 1| println!("used_with_same_type_from_bin_crate_and_lib_crate_generic_function with {:?}", arg);
- | 57| 1|}
- ------------------
- | used_inline_crate::used_with_same_type_from_bin_crate_and_lib_crate_generic_function::<&str>:
- | 55| 2|pub fn used_with_same_type_from_bin_crate_and_lib_crate_generic_function<T: Debug>(arg: T) {
- | 56| 2| println!("used_with_same_type_from_bin_crate_and_lib_crate_generic_function with {:?}", arg);
- | 57| 2|}
- ------------------
- 58| |
- 59| |#[inline(always)]
- 60| 0|pub fn unused_generic_function<T: Debug>(arg: T) {
- 61| 0| println!("unused_generic_function with {:?}", arg);
- 62| 0|}
- 63| |
- 64| |#[inline(always)]
- 65| 0|pub fn unused_function() {
- 66| 0| let is_true = std::env::args().len() == 1;
- 67| 0| let mut countdown = 2;
- 68| 0| if !is_true {
- 69| 0| countdown = 20;
- 70| 0| }
- 71| 0|}
- 72| |
- 73| |#[inline(always)]
- 74| 0|fn unused_private_function() {
- 75| 0| let is_true = std::env::args().len() == 1;
- 76| 0| let mut countdown = 2;
- 77| 0| if !is_true {
- 78| 0| countdown = 20;
- 79| 0| }
- 80| 0|}
- 81| |
- 82| 2|fn use_this_lib_crate() {
- 83| 2| used_from_bin_crate_and_lib_crate_generic_function("used from library used_crate.rs");
- 84| 2| used_with_same_type_from_bin_crate_and_lib_crate_generic_function(
- 85| 2| "used from library used_crate.rs",
- 86| 2| );
- 87| 2| let some_vec = vec![5, 6, 7, 8];
- 88| 2| used_only_from_this_lib_crate_generic_function(some_vec);
- 89| 2| used_only_from_this_lib_crate_generic_function("used ONLY from library used_crate.rs");
- 90| 2|}
-
diff --git a/tests/run-make/coverage-reports/expected_show_coverage.while.txt b/tests/run-make/coverage-reports/expected_show_coverage.while.txt
deleted file mode 100644
index efa7d083f..000000000
--- a/tests/run-make/coverage-reports/expected_show_coverage.while.txt
+++ /dev/null
@@ -1,6 +0,0 @@
- 1| 1|fn main() {
- 2| 1| let num = 9;
- 3| 1| while num >= 10 {
- 4| 0| }
- 5| 1|}
-
diff --git a/tests/run-make/coverage-reports/expected_show_coverage.while_early_ret.txt b/tests/run-make/coverage-reports/expected_show_coverage.while_early_ret.txt
deleted file mode 100644
index d19afc0de..000000000
--- a/tests/run-make/coverage-reports/expected_show_coverage.while_early_ret.txt
+++ /dev/null
@@ -1,43 +0,0 @@
- 1| |#![allow(unused_assignments)]
- 2| |// expect-exit-status-1
- 3| |
- 4| 1|fn main() -> Result<(),u8> {
- 5| 1| let mut countdown = 10;
- 6| | while
- 7| 7| countdown
- 8| 7| >
- 9| 7| 0
- 10| | {
- 11| | if
- 12| 7| countdown
- 13| 7| <
- 14| 7| 5
- 15| | {
- 16| | return
- 17| | if
- 18| 1| countdown
- 19| 1| >
- 20| 1| 8
- 21| | {
- 22| 0| Ok(())
- 23| | }
- 24| | else
- 25| | {
- 26| 1| Err(1)
- 27| | }
- 28| | ;
- 29| 6| }
- 30| 6| countdown
- 31| 6| -=
- 32| 6| 1
- 33| | ;
- 34| | }
- 35| 0| Ok(())
- 36| 1|}
- 37| |
- 38| |// ISSUE(77553): Originally, this test had `Err(1)` on line 22 (instead of `Ok(())`) and
- 39| |// `std::process::exit(2)` on line 26 (instead of `Err(1)`); and this worked as expected on Linux
- 40| |// and MacOS. But on Windows (MSVC, at least), the call to `std::process::exit()` exits the program
- 41| |// without saving the InstrProf coverage counters. The use of `std::process:exit()` is not critical
- 42| |// to the coverage test for early returns, but this is a limitation that should be fixed.
-
diff --git a/tests/run-make/coverage-reports/expected_show_coverage.yield.txt b/tests/run-make/coverage-reports/expected_show_coverage.yield.txt
deleted file mode 100644
index 6e2f23ee7..000000000
--- a/tests/run-make/coverage-reports/expected_show_coverage.yield.txt
+++ /dev/null
@@ -1,38 +0,0 @@
- 1| |#![feature(generators, generator_trait)]
- 2| |#![allow(unused_assignments)]
- 3| |
- 4| |use std::ops::{Generator, GeneratorState};
- 5| |use std::pin::Pin;
- 6| |
- 7| 1|fn main() {
- 8| 1| let mut generator = || {
- 9| 1| yield 1;
- 10| 1| return "foo"
- 11| 1| };
- 12| |
- 13| 1| match Pin::new(&mut generator).resume(()) {
- 14| 1| GeneratorState::Yielded(1) => {}
- 15| 0| _ => panic!("unexpected value from resume"),
- 16| | }
- 17| 1| match Pin::new(&mut generator).resume(()) {
- 18| 1| GeneratorState::Complete("foo") => {}
- 19| 0| _ => panic!("unexpected value from resume"),
- 20| | }
- 21| |
- 22| 1| let mut generator = || {
- 23| 1| yield 1;
- 24| 1| yield 2;
- 25| 0| yield 3;
- 26| 0| return "foo"
- 27| 0| };
- 28| |
- 29| 1| match Pin::new(&mut generator).resume(()) {
- 30| 1| GeneratorState::Yielded(1) => {}
- 31| 0| _ => panic!("unexpected value from resume"),
- 32| | }
- 33| 1| match Pin::new(&mut generator).resume(()) {
- 34| 1| GeneratorState::Yielded(2) => {}
- 35| 0| _ => panic!("unexpected value from resume"),
- 36| | }
- 37| 1|}
-
diff --git a/tests/run-make/coverage-reports/normalize_paths.py b/tests/run-make/coverage-reports/normalize_paths.py
deleted file mode 100755
index e5777ad25..000000000
--- a/tests/run-make/coverage-reports/normalize_paths.py
+++ /dev/null
@@ -1,12 +0,0 @@
-#!/usr/bin/env python
-
-from __future__ import print_function
-
-import sys
-
-# Normalize file paths in output
-for line in sys.stdin:
- if line.startswith("..") and line.rstrip().endswith(".rs:"):
- print(line.replace("\\", "/"), end='')
- else:
- print(line, end='')
diff --git a/tests/run-make/coverage-reports/sort_subviews.py b/tests/run-make/coverage-reports/sort_subviews.py
deleted file mode 100644
index 10cfc51d4..000000000
--- a/tests/run-make/coverage-reports/sort_subviews.py
+++ /dev/null
@@ -1,50 +0,0 @@
-#!/usr/bin/env python3
-
-# `llvm-cov show` prints grouped subviews (e.g. for generic functions) in an
-# unstable order, which is inconvenient when checking output snapshots with
-# `diff`. To work around that, this script detects consecutive subviews in its
-# piped input, and sorts them while preserving their contents.
-
-from __future__ import print_function
-
-import sys
-
-
-def main():
- subviews = []
-
- def flush_subviews():
- if not subviews:
- return
-
- # The last "subview" should be just a boundary line on its own, so
- # temporarily remove it before sorting the accumulated subviews.
- terminator = subviews.pop()
- subviews.sort()
- subviews.append(terminator)
-
- for view in subviews:
- for line in view:
- print(line, end="")
-
- subviews.clear()
-
- for line in sys.stdin:
- if line.startswith(" ------------------"):
- # This is a subview boundary line, so start a new subview.
- subviews.append([line])
- elif line.startswith(" |"):
- # Add this line to the current subview.
- subviews[-1].append(line)
- else:
- # This line is not part of a subview, so sort and print any
- # accumulated subviews, and then print the line as-is.
- flush_subviews()
- print(line, end="")
-
- flush_subviews()
- assert not subviews
-
-
-if __name__ == "__main__":
- main()
diff --git a/tests/run-make/coverage/WARNING_KEEP_NAMES_SHORT.txt b/tests/run-make/coverage/WARNING_KEEP_NAMES_SHORT.txt
deleted file mode 100644
index 6a1403b8a..000000000
--- a/tests/run-make/coverage/WARNING_KEEP_NAMES_SHORT.txt
+++ /dev/null
@@ -1,10 +0,0 @@
-IMPORTANT: The Rust test programs in this directory generate various output
-files in the `../coverage*` directories (`expected` and `actual` files).
-
-Microsoft Windows has a relatively short limit on file paths (not individual
-path components, but the entire path). The files generated by these
-`../coverage*` tests typically have file paths that include the program
-source file name plus function and type names (depending on the program).
-
-Keep the test file names short, and keep function names and other symbols
-short as well, to avoid hitting the Windows limits.
diff --git a/tests/run-make/coverage/abort.rs b/tests/run-make/coverage/abort.rs
deleted file mode 100644
index 98264bdc1..000000000
--- a/tests/run-make/coverage/abort.rs
+++ /dev/null
@@ -1,66 +0,0 @@
-#![feature(c_unwind)]
-#![allow(unused_assignments)]
-
-extern "C" fn might_abort(should_abort: bool) {
- if should_abort {
- println!("aborting...");
- panic!("panics and aborts");
- } else {
- println!("Don't Panic");
- }
-}
-
-fn main() -> Result<(), u8> {
- let mut countdown = 10;
- while countdown > 0 {
- if countdown < 5 {
- might_abort(false);
- }
- // See discussion (below the `Notes` section) on coverage results for the closing brace.
- if countdown < 5 { might_abort(false); } // Counts for different regions on one line.
- // For the following example, the closing brace is the last character on the line.
- // This shows the character after the closing brace is highlighted, even if that next
- // character is a newline.
- if countdown < 5 { might_abort(false); }
- countdown -= 1;
- }
- Ok(())
-}
-
-// Notes:
-// 1. Compare this program and its coverage results to those of the similar tests
-// `panic_unwind.rs` and `try_error_result.rs`.
-// 2. This test confirms the coverage generated when a program includes `UnwindAction::Terminate`.
-// 3. The test does not invoke the abort. By executing to a successful completion, the coverage
-// results show where the program did and did not execute.
-// 4. If the program actually aborted, the coverage counters would not be saved (which "works as
-// intended"). Coverage results would show no executed coverage regions.
-// 6. If `should_abort` is `true` and the program aborts, the program exits with a `132` status
-// (on Linux at least).
-
-/*
-
-Expect the following coverage results:
-
-```text
- 16| 11| while countdown > 0 {
- 17| 10| if countdown < 5 {
- 18| 4| might_abort(false);
- 19| 6| }
-```
-
-This is actually correct.
-
-The condition `countdown < 5` executed 10 times (10 loop iterations).
-
-It evaluated to `true` 4 times, and executed the `might_abort()` call.
-
-It skipped the body of the `might_abort()` call 6 times. If an `if` does not include an explicit
-`else`, the coverage implementation injects a counter, at the character immediately after the `if`s
-closing brace, to count the "implicit" `else`. This is the only way to capture the coverage of the
-non-true condition.
-
-As another example of why this is important, say the condition was `countdown < 50`, which is always
-`true`. In that case, we wouldn't have a test for what happens if `might_abort()` is not called.
-The closing brace would have a count of `0`, highlighting the missed coverage.
-*/
diff --git a/tests/run-make/coverage/assert.rs b/tests/run-make/coverage/assert.rs
deleted file mode 100644
index c85f2748e..000000000
--- a/tests/run-make/coverage/assert.rs
+++ /dev/null
@@ -1,32 +0,0 @@
-#![allow(unused_assignments)]
-// expect-exit-status-101
-
-fn might_fail_assert(one_plus_one: u32) {
- println!("does 1 + 1 = {}?", one_plus_one);
- assert_eq!(1 + 1, one_plus_one, "the argument was wrong");
-}
-
-fn main() -> Result<(),u8> {
- let mut countdown = 10;
- while countdown > 0 {
- if countdown == 1 {
- might_fail_assert(3);
- } else if countdown < 5 {
- might_fail_assert(2);
- }
- countdown -= 1;
- }
- Ok(())
-}
-
-// Notes:
-// 1. Compare this program and its coverage results to those of the very similar test
-// `panic_unwind.rs`, and similar tests `abort.rs` and `try_error_result.rs`.
-// 2. This test confirms the coverage generated when a program passes or fails an `assert!()` or
-// related `assert_*!()` macro.
-// 3. Notably, the `assert` macros *do not* generate `TerminatorKind::Assert`. The macros produce
-// conditional expressions, `TerminatorKind::SwitchInt` branches, and a possible call to
-// `begin_panic_fmt()` (that begins a panic unwind, if the assertion test fails).
-// 4. `TerminatoKind::Assert` is, however, also present in the MIR generated for this test
-// (and in many other coverage tests). The `Assert` terminator is typically generated by the
-// Rust compiler to check for runtime failures, such as numeric overflows.
diff --git a/tests/run-make/coverage/async.rs b/tests/run-make/coverage/async.rs
deleted file mode 100644
index efd9e62d6..000000000
--- a/tests/run-make/coverage/async.rs
+++ /dev/null
@@ -1,128 +0,0 @@
-#![allow(unused_assignments, dead_code)]
-
-// compile-flags: --edition=2018 -C opt-level=1
-
-async fn c(x: u8) -> u8 {
- if x == 8 {
- 1
- } else {
- 0
- }
-}
-
-async fn d() -> u8 { 1 }
-
-async fn e() -> u8 { 1 } // unused function; executor does not block on `g()`
-
-async fn f() -> u8 { 1 }
-
-async fn foo() -> [bool; 10] { [false; 10] } // unused function; executor does not block on `h()`
-
-pub async fn g(x: u8) {
- match x {
- y if e().await == y => (),
- y if f().await == y => (),
- _ => (),
- }
-}
-
-async fn h(x: usize) { // The function signature is counted when called, but the body is not
- // executed (not awaited) so the open brace has a `0` count (at least when
- // displayed with `llvm-cov show` in color-mode).
- match x {
- y if foo().await[y] => (),
- _ => (),
- }
-}
-
-async fn i(x: u8) { // line coverage is 1, but there are 2 regions:
- // (a) the function signature, counted when the function is called; and
- // (b) the open brace for the function body, counted once when the body is
- // executed asynchronously.
- match x {
- y if c(x).await == y + 1 => { d().await; }
- y if f().await == y + 1 => (),
- _ => (),
- }
-}
-
-fn j(x: u8) {
- // non-async versions of `c()`, `d()`, and `f()` to make it similar to async `i()`.
- fn c(x: u8) -> u8 {
- if x == 8 {
- 1 // This line appears covered, but the 1-character expression span covering the `1`
- // is not executed. (`llvm-cov show` displays a `^0` below the `1` ). This is because
- // `fn j()` executes the open brace for the function body, followed by the function's
- // first executable statement, `match x`. Inner function declarations are not
- // "visible" to the MIR for `j()`, so the code region counts all lines between the
- // open brace and the first statement as executed, which is, in a sense, true.
- // `llvm-cov show` overcomes this kind of situation by showing the actual counts
- // of the enclosed coverages, (that is, the `1` expression was not executed, and
- // accurately displays a `0`).
- } else {
- 0
- }
- }
- fn d() -> u8 { 1 } // inner function is defined in-line, but the function is not executed
- fn f() -> u8 { 1 }
- match x {
- y if c(x) == y + 1 => { d(); }
- y if f() == y + 1 => (),
- _ => (),
- }
-}
-
-fn k(x: u8) { // unused function
- match x {
- 1 => (),
- 2 => (),
- _ => (),
- }
-}
-
-fn l(x: u8) {
- match x {
- 1 => (),
- 2 => (),
- _ => (),
- }
-}
-
-async fn m(x: u8) -> u8 { x - 1 }
-
-fn main() {
- let _ = g(10);
- let _ = h(9);
- let mut future = Box::pin(i(8));
- j(7);
- l(6);
- let _ = m(5);
- executor::block_on(future.as_mut());
-}
-
-mod executor {
- use core::{
- future::Future,
- pin::Pin,
- task::{Context, Poll, RawWaker, RawWakerVTable, Waker},
- };
-
- pub fn block_on<F: Future>(mut future: F) -> F::Output {
- let mut future = unsafe { Pin::new_unchecked(&mut future) };
- use std::hint::unreachable_unchecked;
- static VTABLE: RawWakerVTable = RawWakerVTable::new(
- |_| unsafe { unreachable_unchecked() }, // clone
- |_| unsafe { unreachable_unchecked() }, // wake
- |_| unsafe { unreachable_unchecked() }, // wake_by_ref
- |_| (),
- );
- let waker = unsafe { Waker::from_raw(RawWaker::new(core::ptr::null(), &VTABLE)) };
- let mut context = Context::from_waker(&waker);
-
- loop {
- if let Poll::Ready(val) = future.as_mut().poll(&mut context) {
- break val;
- }
- }
- }
-}
diff --git a/tests/run-make/coverage/async2.rs b/tests/run-make/coverage/async2.rs
deleted file mode 100644
index 959d48ce9..000000000
--- a/tests/run-make/coverage/async2.rs
+++ /dev/null
@@ -1,69 +0,0 @@
-// compile-flags: --edition=2018
-
-use core::{
- future::Future,
- marker::Send,
- pin::Pin,
-};
-
-fn non_async_func() {
- println!("non_async_func was covered");
- let b = true;
- if b {
- println!("non_async_func println in block");
- }
-}
-
-
-
-
-async fn async_func() {
- println!("async_func was covered");
- let b = true;
- if b {
- println!("async_func println in block");
- }
-}
-
-
-
-
-async fn async_func_just_println() {
- println!("async_func_just_println was covered");
-}
-
-fn main() {
- println!("codecovsample::main");
-
- non_async_func();
-
- executor::block_on(async_func());
- executor::block_on(async_func_just_println());
-}
-
-mod executor {
- use core::{
- future::Future,
- pin::Pin,
- task::{Context, Poll, RawWaker, RawWakerVTable, Waker},
- };
-
- pub fn block_on<F: Future>(mut future: F) -> F::Output {
- let mut future = unsafe { Pin::new_unchecked(&mut future) };
- use std::hint::unreachable_unchecked;
- static VTABLE: RawWakerVTable = RawWakerVTable::new(
- |_| unsafe { unreachable_unchecked() }, // clone
- |_| unsafe { unreachable_unchecked() }, // wake
- |_| unsafe { unreachable_unchecked() }, // wake_by_ref
- |_| (),
- );
- let waker = unsafe { Waker::from_raw(RawWaker::new(core::ptr::null(), &VTABLE)) };
- let mut context = Context::from_waker(&waker);
-
- loop {
- if let Poll::Ready(val) = future.as_mut().poll(&mut context) {
- break val;
- }
- }
- }
-}
diff --git a/tests/run-make/coverage/closure.rs b/tests/run-make/coverage/closure.rs
deleted file mode 100644
index 32ec0bcdf..000000000
--- a/tests/run-make/coverage/closure.rs
+++ /dev/null
@@ -1,215 +0,0 @@
-#![allow(unused_assignments, unused_variables)]
-// compile-flags: -C opt-level=2 # fix described in rustc_middle/mir/mono.rs
-fn main() {
- // Initialize test constants in a way that cannot be determined at compile time, to ensure
- // rustc and LLVM cannot optimize out statements (or coverage counters) downstream from
- // dependent conditions.
- let is_true = std::env::args().len() == 1;
- let is_false = ! is_true;
-
- let mut some_string = Some(String::from("the string content"));
- println!(
- "The string or alt: {}"
- ,
- some_string
- .
- unwrap_or_else
- (
- ||
- {
- let mut countdown = 0;
- if is_false {
- countdown = 10;
- }
- "alt string 1".to_owned()
- }
- )
- );
-
- some_string = Some(String::from("the string content"));
- let
- a
- =
- ||
- {
- let mut countdown = 0;
- if is_false {
- countdown = 10;
- }
- "alt string 2".to_owned()
- };
- println!(
- "The string or alt: {}"
- ,
- some_string
- .
- unwrap_or_else
- (
- a
- )
- );
-
- some_string = None;
- println!(
- "The string or alt: {}"
- ,
- some_string
- .
- unwrap_or_else
- (
- ||
- {
- let mut countdown = 0;
- if is_false {
- countdown = 10;
- }
- "alt string 3".to_owned()
- }
- )
- );
-
- some_string = None;
- let
- a
- =
- ||
- {
- let mut countdown = 0;
- if is_false {
- countdown = 10;
- }
- "alt string 4".to_owned()
- };
- println!(
- "The string or alt: {}"
- ,
- some_string
- .
- unwrap_or_else
- (
- a
- )
- );
-
- let
- quote_closure
- =
- |val|
- {
- let mut countdown = 0;
- if is_false {
- countdown = 10;
- }
- format!("'{}'", val)
- };
- println!(
- "Repeated, quoted string: {:?}"
- ,
- std::iter::repeat("repeat me")
- .take(5)
- .map
- (
- quote_closure
- )
- .collect::<Vec<_>>()
- );
-
- let
- _unused_closure
- =
- |
- mut countdown
- |
- {
- if is_false {
- countdown = 10;
- }
- "closure should be unused".to_owned()
- };
-
- let mut countdown = 10;
- let _short_unused_closure = | _unused_arg: u8 | countdown += 1;
-
-
- let short_used_covered_closure_macro = | used_arg: u8 | println!("called");
- let short_used_not_covered_closure_macro = | used_arg: u8 | println!("not called");
- let _short_unused_closure_macro = | _unused_arg: u8 | println!("not called");
-
-
-
-
- let _short_unused_closure_block = | _unused_arg: u8 | { println!("not called") };
-
- let _shortish_unused_closure = | _unused_arg: u8 | {
- println!("not called")
- };
-
- let _as_short_unused_closure = |
- _unused_arg: u8
- | { println!("not called") };
-
- let _almost_as_short_unused_closure = |
- _unused_arg: u8
- | { println!("not called") }
- ;
-
-
-
-
-
- let _short_unused_closure_line_break_no_block = | _unused_arg: u8 |
-println!("not called")
- ;
-
- let _short_unused_closure_line_break_no_block2 =
- | _unused_arg: u8 |
- println!(
- "not called"
- )
- ;
-
- let short_used_not_covered_closure_line_break_no_block_embedded_branch =
- | _unused_arg: u8 |
- println!(
- "not called: {}",
- if is_true { "check" } else { "me" }
- )
- ;
-
- let short_used_not_covered_closure_line_break_block_embedded_branch =
- | _unused_arg: u8 |
- {
- println!(
- "not called: {}",
- if is_true { "check" } else { "me" }
- )
- }
- ;
-
- let short_used_covered_closure_line_break_no_block_embedded_branch =
- | _unused_arg: u8 |
- println!(
- "not called: {}",
- if is_true { "check" } else { "me" }
- )
- ;
-
- let short_used_covered_closure_line_break_block_embedded_branch =
- | _unused_arg: u8 |
- {
- println!(
- "not called: {}",
- if is_true { "check" } else { "me" }
- )
- }
- ;
-
- if is_false {
- short_used_not_covered_closure_macro(0);
- short_used_not_covered_closure_line_break_no_block_embedded_branch(0);
- short_used_not_covered_closure_line_break_block_embedded_branch(0);
- }
- short_used_covered_closure_macro(0);
- short_used_covered_closure_line_break_no_block_embedded_branch(0);
- short_used_covered_closure_line_break_block_embedded_branch(0);
-}
diff --git a/tests/run-make/coverage/closure_macro.rs b/tests/run-make/coverage/closure_macro.rs
deleted file mode 100644
index 5e3b00d1e..000000000
--- a/tests/run-make/coverage/closure_macro.rs
+++ /dev/null
@@ -1,40 +0,0 @@
-// compile-flags: --edition=2018
-#![feature(no_coverage)]
-
-macro_rules! bail {
- ($msg:literal $(,)?) => {
- if $msg.len() > 0 {
- println!("no msg");
- } else {
- println!($msg);
- }
- return Err(String::from($msg));
- };
-}
-
-macro_rules! on_error {
- ($value:expr, $error_message:expr) => {
- $value.or_else(|e| { // FIXME(85000): no coverage in closure macros
- let message = format!($error_message, e);
- if message.len() > 0 {
- println!("{}", message);
- Ok(String::from("ok"))
- } else {
- bail!("error");
- }
- })
- };
-}
-
-fn load_configuration_files() -> Result<String, String> {
- Ok(String::from("config"))
-}
-
-pub fn main() -> Result<(), String> {
- println!("Starting service");
- let config = on_error!(load_configuration_files(), "Error loading configs: {}")?;
-
- let startup_delay_duration = String::from("arg");
- let _ = (config, startup_delay_duration);
- Ok(())
-}
diff --git a/tests/run-make/coverage/closure_macro_async.rs b/tests/run-make/coverage/closure_macro_async.rs
deleted file mode 100644
index e3e89e9c8..000000000
--- a/tests/run-make/coverage/closure_macro_async.rs
+++ /dev/null
@@ -1,81 +0,0 @@
-// compile-flags: --edition=2018
-#![feature(no_coverage)]
-
-macro_rules! bail {
- ($msg:literal $(,)?) => {
- if $msg.len() > 0 {
- println!("no msg");
- } else {
- println!($msg);
- }
- return Err(String::from($msg));
- };
-}
-
-macro_rules! on_error {
- ($value:expr, $error_message:expr) => {
- $value.or_else(|e| { // FIXME(85000): no coverage in closure macros
- let message = format!($error_message, e);
- if message.len() > 0 {
- println!("{}", message);
- Ok(String::from("ok"))
- } else {
- bail!("error");
- }
- })
- };
-}
-
-fn load_configuration_files() -> Result<String, String> {
- Ok(String::from("config"))
-}
-
-pub async fn test() -> Result<(), String> {
- println!("Starting service");
- let config = on_error!(load_configuration_files(), "Error loading configs: {}")?;
-
- let startup_delay_duration = String::from("arg");
- let _ = (config, startup_delay_duration);
- Ok(())
-}
-
-#[no_coverage]
-fn main() {
- executor::block_on(test());
-}
-
-mod executor {
- use core::{
- future::Future,
- pin::Pin,
- task::{Context, Poll, RawWaker, RawWakerVTable, Waker},
- };
-
- #[no_coverage]
- pub fn block_on<F: Future>(mut future: F) -> F::Output {
- let mut future = unsafe { Pin::new_unchecked(&mut future) };
- use std::hint::unreachable_unchecked;
- static VTABLE: RawWakerVTable = RawWakerVTable::new(
-
- #[no_coverage]
- |_| unsafe { unreachable_unchecked() }, // clone
-
- #[no_coverage]
- |_| unsafe { unreachable_unchecked() }, // wake
-
- #[no_coverage]
- |_| unsafe { unreachable_unchecked() }, // wake_by_ref
-
- #[no_coverage]
- |_| (),
- );
- let waker = unsafe { Waker::from_raw(RawWaker::new(core::ptr::null(), &VTABLE)) };
- let mut context = Context::from_waker(&waker);
-
- loop {
- if let Poll::Ready(val) = future.as_mut().poll(&mut context) {
- break val;
- }
- }
- }
-}
diff --git a/tests/run-make/coverage/compiletest-ignore-dir b/tests/run-make/coverage/compiletest-ignore-dir
deleted file mode 100644
index 470ff9960..000000000
--- a/tests/run-make/coverage/compiletest-ignore-dir
+++ /dev/null
@@ -1,3 +0,0 @@
-# Directory "coverage" supports the tests at prefix ../coverage-*
-
-# Use ./x.py [options] test tests/run-make/coverage to run all related tests.
diff --git a/tests/run-make/coverage/conditions.rs b/tests/run-make/coverage/conditions.rs
deleted file mode 100644
index 057599d1b..000000000
--- a/tests/run-make/coverage/conditions.rs
+++ /dev/null
@@ -1,87 +0,0 @@
-#![allow(unused_assignments, unused_variables)]
-
-fn main() {
- let mut countdown = 0;
- if true {
- countdown = 10;
- }
-
- const B: u32 = 100;
- let x = if countdown > 7 {
- countdown -= 4;
- B
- } else if countdown > 2 {
- if countdown < 1 || countdown > 5 || countdown != 9 {
- countdown = 0;
- }
- countdown -= 5;
- countdown
- } else {
- return;
- };
-
- let mut countdown = 0;
- if true {
- countdown = 10;
- }
-
- if countdown > 7 {
- countdown -= 4;
- } else if countdown > 2 {
- if countdown < 1 || countdown > 5 || countdown != 9 {
- countdown = 0;
- }
- countdown -= 5;
- } else {
- return;
- }
-
- if true {
- let mut countdown = 0;
- if true {
- countdown = 10;
- }
-
- if countdown > 7 {
- countdown -= 4;
- }
- else if countdown > 2 {
- if countdown < 1 || countdown > 5 || countdown != 9 {
- countdown = 0;
- }
- countdown -= 5;
- } else {
- return;
- }
- }
-
-
- let mut countdown = 0;
- if true {
- countdown = 1;
- }
-
- let z = if countdown > 7 {
- countdown -= 4;
- } else if countdown > 2 {
- if countdown < 1 || countdown > 5 || countdown != 9 {
- countdown = 0;
- }
- countdown -= 5;
- } else {
- let should_be_reachable = countdown;
- println!("reached");
- return;
- };
-
- let w = if countdown > 7 {
- countdown -= 4;
- } else if countdown > 2 {
- if countdown < 1 || countdown > 5 || countdown != 9 {
- countdown = 0;
- }
- countdown -= 5;
- } else {
- return;
- };
-}
diff --git a/tests/run-make/coverage/continue.rs b/tests/run-make/coverage/continue.rs
deleted file mode 100644
index 624aa9834..000000000
--- a/tests/run-make/coverage/continue.rs
+++ /dev/null
@@ -1,69 +0,0 @@
-#![allow(unused_assignments, unused_variables)]
-
-fn main() {
- let is_true = std::env::args().len() == 1;
-
- let mut x = 0;
- for _ in 0..10 {
- match is_true {
- true => {
- continue;
- }
- _ => {
- x = 1;
- }
- }
- x = 3;
- }
- for _ in 0..10 {
- match is_true {
- false => {
- x = 1;
- }
- _ => {
- continue;
- }
- }
- x = 3;
- }
- for _ in 0..10 {
- match is_true {
- true => {
- x = 1;
- }
- _ => {
- continue;
- }
- }
- x = 3;
- }
- for _ in 0..10 {
- if is_true {
- continue;
- }
- x = 3;
- }
- for _ in 0..10 {
- match is_true {
- false => {
- x = 1;
- }
- _ => {
- let _ = x;
- }
- }
- x = 3;
- }
- for _ in 0..10 {
- match is_true {
- false => {
- x = 1;
- }
- _ => {
- break;
- }
- }
- x = 3;
- }
- let _ = x;
-}
diff --git a/tests/run-make/coverage/coverage_tools.mk b/tests/run-make/coverage/coverage_tools.mk
deleted file mode 100644
index 028c020a4..000000000
--- a/tests/run-make/coverage/coverage_tools.mk
+++ /dev/null
@@ -1,6 +0,0 @@
-# Common Makefile include for Rust `run-make/coverage-* tests. Include this
-# file with the line:
-#
-# include ../coverage/coverage_tools.mk
-
-include ../tools.mk
diff --git a/tests/run-make/coverage/dead_code.rs b/tests/run-make/coverage/dead_code.rs
deleted file mode 100644
index a1285df0e..000000000
--- a/tests/run-make/coverage/dead_code.rs
+++ /dev/null
@@ -1,37 +0,0 @@
-#![allow(unused_assignments, unused_variables)]
-
-pub fn unused_pub_fn_not_in_library() {
- // Initialize test constants in a way that cannot be determined at compile time, to ensure
- // rustc and LLVM cannot optimize out statements (or coverage counters) downstream from
- // dependent conditions.
- let is_true = std::env::args().len() == 1;
-
- let mut countdown = 0;
- if is_true {
- countdown = 10;
- }
-}
-
-fn unused_fn() {
- // Initialize test constants in a way that cannot be determined at compile time, to ensure
- // rustc and LLVM cannot optimize out statements (or coverage counters) downstream from
- // dependent conditions.
- let is_true = std::env::args().len() == 1;
-
- let mut countdown = 0;
- if is_true {
- countdown = 10;
- }
-}
-
-fn main() {
- // Initialize test constants in a way that cannot be determined at compile time, to ensure
- // rustc and LLVM cannot optimize out statements (or coverage counters) downstream from
- // dependent conditions.
- let is_true = std::env::args().len() == 1;
-
- let mut countdown = 0;
- if is_true {
- countdown = 10;
- }
-}
diff --git a/tests/run-make/coverage/doctest.rs b/tests/run-make/coverage/doctest.rs
deleted file mode 100644
index ec04ea570..000000000
--- a/tests/run-make/coverage/doctest.rs
+++ /dev/null
@@ -1,99 +0,0 @@
-//! This test ensures that code from doctests is properly re-mapped.
-//! See <https://github.com/rust-lang/rust/issues/79417> for more info.
-//!
-//! Just some random code:
-//! ```
-//! if true {
-//! // this is executed!
-//! assert_eq!(1, 1);
-//! } else {
-//! // this is not!
-//! assert_eq!(1, 2);
-//! }
-//! ```
-//!
-//! doctest testing external code:
-//! ```
-//! extern crate doctest_crate;
-//! doctest_crate::fn_run_in_doctests(1);
-//! ```
-//!
-//! doctest returning a result:
-//! ```
-//! #[derive(Debug, PartialEq)]
-//! struct SomeError {
-//! msg: String,
-//! }
-//! let mut res = Err(SomeError { msg: String::from("a message") });
-//! if res.is_ok() {
-//! res?;
-//! } else {
-//! if *res.as_ref().unwrap_err() == *res.as_ref().unwrap_err() {
-//! println!("{:?}", res);
-//! }
-//! if *res.as_ref().unwrap_err() == *res.as_ref().unwrap_err() {
-//! res = Ok(1);
-//! }
-//! res = Ok(0);
-//! }
-//! // need to be explicit because rustdoc cant infer the return type
-//! Ok::<(), SomeError>(())
-//! ```
-//!
-//! doctest with custom main:
-//! ```
-//! fn some_func() {
-//! println!("called some_func()");
-//! }
-//!
-//! #[derive(Debug)]
-//! struct SomeError;
-//!
-//! extern crate doctest_crate;
-//!
-//! fn doctest_main() -> Result<(), SomeError> {
-//! some_func();
-//! doctest_crate::fn_run_in_doctests(2);
-//! Ok(())
-//! }
-//!
-//! // this `main` is not shown as covered, as it clashes with all the other
-//! // `main` functions that were automatically generated for doctests
-//! fn main() -> Result<(), SomeError> {
-//! doctest_main()
-//! }
-//! ```
-
-/// doctest attached to fn testing external code:
-/// ```
-/// extern crate doctest_crate;
-/// doctest_crate::fn_run_in_doctests(3);
-/// ```
-///
-fn main() {
- if true {
- assert_eq!(1, 1);
- } else {
- assert_eq!(1, 2);
- }
-}
-
-// FIXME(Swatinem): Fix known issue that coverage code region columns need to be offset by the
-// doc comment line prefix (`///` or `//!`) and any additional indent (before or after the doc
-// comment characters). This test produces `llvm-cov show` results demonstrating the problem.
-//
-// One of the above tests now includes: `derive(Debug, PartialEq)`, producing an `llvm-cov show`
-// result with a distinct count for `Debug`, denoted by `^1`, but the caret points to the wrong
-// column. Similarly, the `if` blocks without `else` blocks show `^0`, which should point at, or
-// one character past, the `if` block's closing brace. In both cases, these are most likely off
-// by the number of characters stripped from the beginning of each doc comment line: indent
-// whitespace, if any, doc comment prefix (`//!` in this case) and (I assume) one space character
-// (?). Note, when viewing `llvm-cov show` results in `--color` mode, the column offset errors are
-// more pronounced, and show up in more places, with background color used to show some distinct
-// code regions with different coverage counts.
-//
-// NOTE: Since the doc comment line prefix may vary, one possible solution is to replace each
-// character stripped from the beginning of doc comment lines with a space. This will give coverage
-// results the correct column offsets, and I think it should compile correctly, but I don't know
-// what affect it might have on diagnostic messages from the compiler, and whether anyone would care
-// if the indentation changed. I don't know if there is a more viable solution.
diff --git a/tests/run-make/coverage/drop_trait.rs b/tests/run-make/coverage/drop_trait.rs
deleted file mode 100644
index d15bfc0f8..000000000
--- a/tests/run-make/coverage/drop_trait.rs
+++ /dev/null
@@ -1,33 +0,0 @@
-#![allow(unused_assignments)]
-// expect-exit-status-1
-
-struct Firework {
- strength: i32,
-}
-
-impl Drop for Firework {
- fn drop(&mut self) {
- println!("BOOM times {}!!!", self.strength);
- }
-}
-
-fn main() -> Result<(),u8> {
- let _firecracker = Firework { strength: 1 };
-
- let _tnt = Firework { strength: 100 };
-
- if true {
- println!("Exiting with error...");
- return Err(1);
- }
-
- let _ = Firework { strength: 1000 };
-
- Ok(())
-}
-
-// Expected program output:
-// Exiting with error...
-// BOOM times 100!!!
-// BOOM times 1!!!
-// Error: 1
diff --git a/tests/run-make/coverage/generator.rs b/tests/run-make/coverage/generator.rs
deleted file mode 100644
index 431999102..000000000
--- a/tests/run-make/coverage/generator.rs
+++ /dev/null
@@ -1,30 +0,0 @@
-#![feature(generators, generator_trait)]
-
-use std::ops::{Generator, GeneratorState};
-use std::pin::Pin;
-
-// The following implementation of a function called from a `yield` statement
-// (apparently requiring the Result and the `String` type or constructor)
-// creates conditions where the `generator::StateTransform` MIR transform will
-// drop all `Counter` `Coverage` statements from a MIR. `simplify.rs` has logic
-// to handle this condition, and still report dead block coverage.
-fn get_u32(val: bool) -> Result<u32, String> {
- if val { Ok(1) } else { Err(String::from("some error")) }
-}
-
-fn main() {
- let is_true = std::env::args().len() == 1;
- let mut generator = || {
- yield get_u32(is_true);
- return "foo";
- };
-
- match Pin::new(&mut generator).resume(()) {
- GeneratorState::Yielded(Ok(1)) => {}
- _ => panic!("unexpected return from resume"),
- }
- match Pin::new(&mut generator).resume(()) {
- GeneratorState::Complete("foo") => {}
- _ => panic!("unexpected return from resume"),
- }
-}
diff --git a/tests/run-make/coverage/generics.rs b/tests/run-make/coverage/generics.rs
deleted file mode 100644
index 18b388684..000000000
--- a/tests/run-make/coverage/generics.rs
+++ /dev/null
@@ -1,48 +0,0 @@
-#![allow(unused_assignments)]
-// expect-exit-status-1
-
-struct Firework<T> where T: Copy + std::fmt::Display {
- strength: T,
-}
-
-impl<T> Firework<T> where T: Copy + std::fmt::Display {
- #[inline(always)]
- fn set_strength(&mut self, new_strength: T) {
- self.strength = new_strength;
- }
-}
-
-impl<T> Drop for Firework<T> where T: Copy + std::fmt::Display {
- #[inline(always)]
- fn drop(&mut self) {
- println!("BOOM times {}!!!", self.strength);
- }
-}
-
-fn main() -> Result<(),u8> {
- let mut firecracker = Firework { strength: 1 };
- firecracker.set_strength(2);
-
- let mut tnt = Firework { strength: 100.1 };
- tnt.set_strength(200.1);
- tnt.set_strength(300.3);
-
- if true {
- println!("Exiting with error...");
- return Err(1);
- }
-
-
-
-
-
- let _ = Firework { strength: 1000 };
-
- Ok(())
-}
-
-// Expected program output:
-// Exiting with error...
-// BOOM times 100!!!
-// BOOM times 1!!!
-// Error: 1
diff --git a/tests/run-make/coverage/if.rs b/tests/run-make/coverage/if.rs
deleted file mode 100644
index 8ad5042ff..000000000
--- a/tests/run-make/coverage/if.rs
+++ /dev/null
@@ -1,28 +0,0 @@
-#![allow(unused_assignments, unused_variables)]
-
-fn main() {
- // Initialize test constants in a way that cannot be determined at compile time, to ensure
- // rustc and LLVM cannot optimize out statements (or coverage counters) downstream from
- // dependent conditions.
- let
- is_true
- =
- std::env::args().len()
- ==
- 1
- ;
- let
- mut
- countdown
- =
- 0
- ;
- if
- is_true
- {
- countdown
- =
- 10
- ;
- }
-}
diff --git a/tests/run-make/coverage/if_else.rs b/tests/run-make/coverage/if_else.rs
deleted file mode 100644
index 3244e1e3a..000000000
--- a/tests/run-make/coverage/if_else.rs
+++ /dev/null
@@ -1,40 +0,0 @@
-#![allow(unused_assignments, unused_variables)]
-
-fn main() {
- // Initialize test constants in a way that cannot be determined at compile time, to ensure
- // rustc and LLVM cannot optimize out statements (or coverage counters) downstream from
- // dependent conditions.
- let is_true = std::env::args().len() == 1;
-
- let mut countdown = 0;
- if
- is_true
- {
- countdown
- =
- 10
- ;
- }
- else // Note coverage region difference without semicolon
- {
- countdown
- =
- 100
- }
-
- if
- is_true
- {
- countdown
- =
- 10
- ;
- }
- else
- {
- countdown
- =
- 100
- ;
- }
-}
diff --git a/tests/run-make/coverage/inline-dead.rs b/tests/run-make/coverage/inline-dead.rs
deleted file mode 100644
index 854fa0629..000000000
--- a/tests/run-make/coverage/inline-dead.rs
+++ /dev/null
@@ -1,27 +0,0 @@
-// Regression test for issue #98833.
-// compile-flags: -Zinline-mir -Cdebug-assertions=off
-
-fn main() {
- println!("{}", live::<false>());
-
- let f = |x: bool| {
- debug_assert!(
- x
- );
- };
- f(false);
-}
-
-#[inline]
-fn live<const B: bool>() -> u32 {
- if B {
- dead()
- } else {
- 0
- }
-}
-
-#[inline]
-fn dead() -> u32 {
- 42
-}
diff --git a/tests/run-make/coverage/inline.rs b/tests/run-make/coverage/inline.rs
deleted file mode 100644
index 9cfab9ddb..000000000
--- a/tests/run-make/coverage/inline.rs
+++ /dev/null
@@ -1,51 +0,0 @@
-// compile-flags: -Zinline-mir
-
-use std::fmt::Display;
-
-fn main() {
- permutations(&['a', 'b', 'c']);
-}
-
-#[inline(always)]
-fn permutations<T: Copy + Display>(xs: &[T]) {
- let mut ys = xs.to_owned();
- permutate(&mut ys, 0);
-}
-
-fn permutate<T: Copy + Display>(xs: &mut [T], k: usize) {
- let n = length(xs);
- if k == n {
- display(xs);
- } else if k < n {
- for i in k..n {
- swap(xs, i, k);
- permutate(xs, k + 1);
- swap(xs, i, k);
- }
- } else {
- error();
- }
-}
-
-fn length<T>(xs: &[T]) -> usize {
- xs.len()
-}
-
-#[inline]
-fn swap<T: Copy>(xs: &mut [T], i: usize, j: usize) {
- let t = xs[i];
- xs[i] = xs[j];
- xs[j] = t;
-}
-
-fn display<T: Display>(xs: &[T]) {
- for x in xs {
- print!("{}", x);
- }
- println!();
-}
-
-#[inline(always)]
-fn error() {
- panic!("error");
-}
diff --git a/tests/run-make/coverage/inner_items.rs b/tests/run-make/coverage/inner_items.rs
deleted file mode 100644
index bcb62b303..000000000
--- a/tests/run-make/coverage/inner_items.rs
+++ /dev/null
@@ -1,57 +0,0 @@
-#![allow(unused_assignments, unused_variables, dead_code)]
-
-fn main() {
- // Initialize test constants in a way that cannot be determined at compile time, to ensure
- // rustc and LLVM cannot optimize out statements (or coverage counters) downstream from
- // dependent conditions.
- let is_true = std::env::args().len() == 1;
-
- let mut countdown = 0;
- if is_true {
- countdown = 10;
- }
-
- mod in_mod {
- const IN_MOD_CONST: u32 = 1000;
- }
-
- fn in_func(a: u32) {
- let b = 1;
- let c = a + b;
- println!("c = {}", c)
- }
-
- struct InStruct {
- in_struct_field: u32,
- }
-
- const IN_CONST: u32 = 1234;
-
- trait InTrait {
- fn trait_func(&mut self, incr: u32);
-
- fn default_trait_func(&mut self) {
- in_func(IN_CONST);
- self.trait_func(IN_CONST);
- }
- }
-
- impl InTrait for InStruct {
- fn trait_func(&mut self, incr: u32) {
- self.in_struct_field += incr;
- in_func(self.in_struct_field);
- }
- }
-
- type InType = String;
-
- if is_true {
- in_func(countdown);
- }
-
- let mut val = InStruct {
- in_struct_field: 101,
- };
-
- val.default_trait_func();
-}
diff --git a/tests/run-make/coverage/issue-83601.rs b/tests/run-make/coverage/issue-83601.rs
deleted file mode 100644
index 0b72a8194..000000000
--- a/tests/run-make/coverage/issue-83601.rs
+++ /dev/null
@@ -1,14 +0,0 @@
-// Shows that rust-lang/rust/83601 is resolved
-
-#[derive(Debug, PartialEq, Eq)]
-struct Foo(u32);
-
-fn main() {
- let bar = Foo(1);
- assert_eq!(bar, Foo(1));
- let baz = Foo(0);
- assert_ne!(baz, Foo(1));
- println!("{:?}", Foo(1));
- println!("{:?}", bar);
- println!("{:?}", baz);
-}
diff --git a/tests/run-make/coverage/issue-84561.rs b/tests/run-make/coverage/issue-84561.rs
deleted file mode 100644
index b39a289c4..000000000
--- a/tests/run-make/coverage/issue-84561.rs
+++ /dev/null
@@ -1,182 +0,0 @@
-// This demonstrated Issue #84561: function-like macros produce unintuitive coverage results.
-
-// expect-exit-status-101
-#[derive(PartialEq, Eq)]
-struct Foo(u32);
-fn test3() {
- let is_true = std::env::args().len() == 1;
- let bar = Foo(1);
- assert_eq!(bar, Foo(1));
- let baz = Foo(0);
- assert_ne!(baz, Foo(1));
- println!("{:?}", Foo(1));
- println!("{:?}", bar);
- println!("{:?}", baz);
-
- assert_eq!(Foo(1), Foo(1));
- assert_ne!(Foo(0), Foo(1));
- assert_eq!(Foo(2), Foo(2));
- let bar = Foo(0);
- assert_ne!(bar, Foo(3));
- assert_ne!(Foo(0), Foo(4));
- assert_eq!(Foo(3), Foo(3), "with a message");
- println!("{:?}", bar);
- println!("{:?}", Foo(1));
-
- assert_ne!(Foo(0), Foo(5), "{}", if is_true { "true message" } else { "false message" });
- assert_ne!(
- Foo(0)
- ,
- Foo(5)
- ,
- "{}"
- ,
- if
- is_true
- {
- "true message"
- } else {
- "false message"
- }
- );
-
- let is_true = std::env::args().len() == 1;
-
- assert_eq!(
- Foo(1),
- Foo(1)
- );
- assert_ne!(
- Foo(0),
- Foo(1)
- );
- assert_eq!(
- Foo(2),
- Foo(2)
- );
- let bar = Foo(1);
- assert_ne!(
- bar,
- Foo(3)
- );
- if is_true {
- assert_ne!(
- Foo(0),
- Foo(4)
- );
- } else {
- assert_eq!(
- Foo(3),
- Foo(3)
- );
- }
- if is_true {
- assert_ne!(
- Foo(0),
- Foo(4),
- "with a message"
- );
- } else {
- assert_eq!(
- Foo(3),
- Foo(3),
- "with a message"
- );
- }
- assert_ne!(
- if is_true {
- Foo(0)
- } else {
- Foo(1)
- },
- Foo(5)
- );
- assert_ne!(
- Foo(5),
- if is_true {
- Foo(0)
- } else {
- Foo(1)
- }
- );
- assert_ne!(
- if is_true {
- assert_eq!(
- Foo(3),
- Foo(3)
- );
- Foo(0)
- } else {
- assert_ne!(
- if is_true {
- Foo(0)
- } else {
- Foo(1)
- },
- Foo(5)
- );
- Foo(1)
- },
- Foo(5),
- "with a message"
- );
- assert_eq!(
- Foo(1),
- Foo(3),
- "this assert should fail"
- );
- assert_eq!(
- Foo(3),
- Foo(3),
- "this assert should not be reached"
- );
-}
-
-impl std::fmt::Debug for Foo {
- fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
- write!(f, "try and succeed")?;
- Ok(())
- }
-}
-
-static mut DEBUG_LEVEL_ENABLED: bool = false;
-
-macro_rules! debug {
- ($($arg:tt)+) => (
- if unsafe { DEBUG_LEVEL_ENABLED } {
- println!($($arg)+);
- }
- );
-}
-
-fn test1() {
- debug!("debug is enabled");
- debug!("debug is enabled");
- let _ = 0;
- debug!("debug is enabled");
- unsafe {
- DEBUG_LEVEL_ENABLED = true;
- }
- debug!("debug is enabled");
-}
-
-macro_rules! call_debug {
- ($($arg:tt)+) => (
- fn call_print(s: &str) {
- print!("{}", s);
- }
-
- call_print("called from call_debug: ");
- debug!($($arg)+);
- );
-}
-
-fn test2() {
- call_debug!("debug is enabled");
-}
-
-fn main() {
- test1();
- test2();
- test3();
-}
diff --git a/tests/run-make/coverage/issue-85461.rs b/tests/run-make/coverage/issue-85461.rs
deleted file mode 100644
index a1b9ebb1e..000000000
--- a/tests/run-make/coverage/issue-85461.rs
+++ /dev/null
@@ -1,10 +0,0 @@
-// Regression test for #85461: MSVC sometimes fail to link with dead code and #[inline(always)]
-
-extern crate inline_always_with_dead_code;
-
-use inline_always_with_dead_code::{bar, baz};
-
-fn main() {
- bar::call_me();
- baz::call_me();
-}
diff --git a/tests/run-make/coverage/issue-93054.rs b/tests/run-make/coverage/issue-93054.rs
deleted file mode 100644
index c160b3db0..000000000
--- a/tests/run-make/coverage/issue-93054.rs
+++ /dev/null
@@ -1,28 +0,0 @@
-// Regression test for #93054: Functions using uninhabited types often only have a single,
-// unreachable basic block which doesn't get instrumented. This should not cause llvm-cov to fail.
-// Since these kinds functions can't be invoked anyway, it's ok to not have coverage data for them.
-
-// compile-flags: --edition=2021
-
-enum Never { }
-
-impl Never {
- fn foo(self) {
- match self { }
- make().map(|never| match never { });
- }
-
- fn bar(&self) {
- match *self { }
- }
-}
-
-async fn foo2(never: Never) {
- match never { }
-}
-
-fn make() -> Option<Never> {
- None
-}
-
-fn main() { }
diff --git a/tests/run-make/coverage/lazy_boolean.rs b/tests/run-make/coverage/lazy_boolean.rs
deleted file mode 100644
index bb6219e85..000000000
--- a/tests/run-make/coverage/lazy_boolean.rs
+++ /dev/null
@@ -1,61 +0,0 @@
-#![allow(unused_assignments, unused_variables)]
-
-fn main() {
- // Initialize test constants in a way that cannot be determined at compile time, to ensure
- // rustc and LLVM cannot optimize out statements (or coverage counters) downstream from
- // dependent conditions.
- let is_true = std::env::args().len() == 1;
-
- let (mut a, mut b, mut c) = (0, 0, 0);
- if is_true {
- a = 1;
- b = 10;
- c = 100;
- }
- let
- somebool
- =
- a < b
- ||
- b < c
- ;
- let
- somebool
- =
- b < a
- ||
- b < c
- ;
- let somebool = a < b && b < c;
- let somebool = b < a && b < c;
-
- if
- !
- is_true
- {
- a = 2
- ;
- }
-
- if
- is_true
- {
- b = 30
- ;
- }
- else
- {
- c = 400
- ;
- }
-
- if !is_true {
- a = 2;
- }
-
- if is_true {
- b = 30;
- } else {
- c = 400;
- }
-}
diff --git a/tests/run-make/coverage/lib/doctest_crate.rs b/tests/run-make/coverage/lib/doctest_crate.rs
deleted file mode 100644
index c3210146d..000000000
--- a/tests/run-make/coverage/lib/doctest_crate.rs
+++ /dev/null
@@ -1,9 +0,0 @@
-/// A function run only from within doctests
-pub fn fn_run_in_doctests(conditional: usize) {
- match conditional {
- 1 => assert_eq!(1, 1), // this is run,
- 2 => assert_eq!(1, 1), // this,
- 3 => assert_eq!(1, 1), // and this too
- _ => assert_eq!(1, 2), // however this is not
- }
-}
diff --git a/tests/run-make/coverage/lib/inline_always_with_dead_code.rs b/tests/run-make/coverage/lib/inline_always_with_dead_code.rs
deleted file mode 100644
index 2b21dee6c..000000000
--- a/tests/run-make/coverage/lib/inline_always_with_dead_code.rs
+++ /dev/null
@@ -1,22 +0,0 @@
-// compile-flags: -Cinstrument-coverage -Ccodegen-units=4 -Copt-level=0
-
-#![allow(dead_code)]
-
-mod foo {
- #[inline(always)]
- pub fn called() { }
-
- fn uncalled() { }
-}
-
-pub mod bar {
- pub fn call_me() {
- super::foo::called();
- }
-}
-
-pub mod baz {
- pub fn call_me() {
- super::foo::called();
- }
-}
diff --git a/tests/run-make/coverage/lib/unused_mod_helper.rs b/tests/run-make/coverage/lib/unused_mod_helper.rs
deleted file mode 100644
index ae1cc1531..000000000
--- a/tests/run-make/coverage/lib/unused_mod_helper.rs
+++ /dev/null
@@ -1,3 +0,0 @@
-pub fn never_called_function() {
- println!("I am never called");
-}
diff --git a/tests/run-make/coverage/lib/used_crate.rs b/tests/run-make/coverage/lib/used_crate.rs
deleted file mode 100644
index 8b8b1f7f3..000000000
--- a/tests/run-make/coverage/lib/used_crate.rs
+++ /dev/null
@@ -1,100 +0,0 @@
-#![allow(unused_assignments, unused_variables)]
-// compile-flags: -C opt-level=3 # validates coverage now works with optimizations
-use std::fmt::Debug;
-
-pub fn used_function() {
- // Initialize test constants in a way that cannot be determined at compile time, to ensure
- // rustc and LLVM cannot optimize out statements (or coverage counters) downstream from
- // dependent conditions.
- let is_true = std::env::args().len() == 1;
- let mut countdown = 0;
- if is_true {
- countdown = 10;
- }
- use_this_lib_crate();
-}
-
-pub fn used_only_from_bin_crate_generic_function<T: Debug>(arg: T) {
- println!("used_only_from_bin_crate_generic_function with {:?}", arg);
-}
-// Expect for above function: `Unexecuted instantiation` (see below)
-pub fn used_only_from_this_lib_crate_generic_function<T: Debug>(arg: T) {
- println!("used_only_from_this_lib_crate_generic_function with {:?}", arg);
-}
-
-pub fn used_from_bin_crate_and_lib_crate_generic_function<T: Debug>(arg: T) {
- println!("used_from_bin_crate_and_lib_crate_generic_function with {:?}", arg);
-}
-
-pub fn used_with_same_type_from_bin_crate_and_lib_crate_generic_function<T: Debug>(arg: T) {
- println!("used_with_same_type_from_bin_crate_and_lib_crate_generic_function with {:?}", arg);
-}
-
-pub fn unused_generic_function<T: Debug>(arg: T) {
- println!("unused_generic_function with {:?}", arg);
-}
-
-pub fn unused_function() {
- let is_true = std::env::args().len() == 1;
- let mut countdown = 2;
- if !is_true {
- countdown = 20;
- }
-}
-
-fn unused_private_function() {
- let is_true = std::env::args().len() == 1;
- let mut countdown = 2;
- if !is_true {
- countdown = 20;
- }
-}
-
-fn use_this_lib_crate() {
- used_from_bin_crate_and_lib_crate_generic_function("used from library used_crate.rs");
- used_with_same_type_from_bin_crate_and_lib_crate_generic_function(
- "used from library used_crate.rs",
- );
- let some_vec = vec![5, 6, 7, 8];
- used_only_from_this_lib_crate_generic_function(some_vec);
- used_only_from_this_lib_crate_generic_function("used ONLY from library used_crate.rs");
-}
-
-// FIXME(#79651): "Unexecuted instantiation" errors appear in coverage results,
-// for example:
-//
-// | Unexecuted instantiation: used_crate::used_only_from_bin_crate_generic_function::<_>
-//
-// These notices appear when `llvm-cov` shows instantiations. This may be a
-// default option, but it can be suppressed with:
-//
-// ```shell
-// $ `llvm-cov show --show-instantiations=0 ...`
-// ```
-//
-// The notice is triggered because the function is unused by the library itself,
-// and when the library is compiled, a synthetic function is generated, so
-// unused function coverage can be reported. Coverage can be skipped for unused
-// generic functions with:
-//
-// ```shell
-// $ `rustc -Zunstable-options -C instrument-coverage=except-unused-generics ...`
-// ```
-//
-// Even though this function is used by `uses_crate.rs` (and
-// counted), with substitutions for `T`, those instantiations are only generated
-// when the generic function is actually used (from the binary, not from this
-// library crate). So the test result shows coverage for all instantiated
-// versions and their generic type substitutions, plus the `Unexecuted
-// instantiation` message for the non-substituted version. This is valid, but
-// unfortunately a little confusing.
-//
-// The library crate has its own coverage map, and the only way to show unused
-// coverage of a generic function is to include the generic function in the
-// coverage map, marked as an "unused function". If the library were used by
-// another binary that never used this generic function, then it would be valid
-// to show the unused generic, with unknown substitution (`_`).
-//
-// The alternative is to exclude all generics from being included in the "unused
-// functions" list, which would then omit coverage results for
-// `unused_generic_function<T>()`, below.
diff --git a/tests/run-make/coverage/lib/used_inline_crate.rs b/tests/run-make/coverage/lib/used_inline_crate.rs
deleted file mode 100644
index 4a052756d..000000000
--- a/tests/run-make/coverage/lib/used_inline_crate.rs
+++ /dev/null
@@ -1,90 +0,0 @@
-#![allow(unused_assignments, unused_variables)]
-
-// compile-flags: -C opt-level=3 # validates coverage now works with optimizations
-
-use std::fmt::Debug;
-
-pub fn used_function() {
- // Initialize test constants in a way that cannot be determined at compile time, to ensure
- // rustc and LLVM cannot optimize out statements (or coverage counters) downstream from
- // dependent conditions.
- let is_true = std::env::args().len() == 1;
- let mut countdown = 0;
- if is_true {
- countdown = 10;
- }
- use_this_lib_crate();
-}
-
-#[inline(always)]
-pub fn used_inline_function() {
- // Initialize test constants in a way that cannot be determined at compile time, to ensure
- // rustc and LLVM cannot optimize out statements (or coverage counters) downstream from
- // dependent conditions.
- let is_true = std::env::args().len() == 1;
- let mut countdown = 0;
- if is_true {
- countdown = 10;
- }
- use_this_lib_crate();
-}
-
-
-
-
-
-
-
-#[inline(always)]
-pub fn used_only_from_bin_crate_generic_function<T: Debug>(arg: T) {
- println!("used_only_from_bin_crate_generic_function with {:?}", arg);
-}
-// Expect for above function: `Unexecuted instantiation` (see notes in `used_crate.rs`)
-
-#[inline(always)]
-pub fn used_only_from_this_lib_crate_generic_function<T: Debug>(arg: T) {
- println!("used_only_from_this_lib_crate_generic_function with {:?}", arg);
-}
-
-#[inline(always)]
-pub fn used_from_bin_crate_and_lib_crate_generic_function<T: Debug>(arg: T) {
- println!("used_from_bin_crate_and_lib_crate_generic_function with {:?}", arg);
-}
-
-#[inline(always)]
-pub fn used_with_same_type_from_bin_crate_and_lib_crate_generic_function<T: Debug>(arg: T) {
- println!("used_with_same_type_from_bin_crate_and_lib_crate_generic_function with {:?}", arg);
-}
-
-#[inline(always)]
-pub fn unused_generic_function<T: Debug>(arg: T) {
- println!("unused_generic_function with {:?}", arg);
-}
-
-#[inline(always)]
-pub fn unused_function() {
- let is_true = std::env::args().len() == 1;
- let mut countdown = 2;
- if !is_true {
- countdown = 20;
- }
-}
-
-#[inline(always)]
-fn unused_private_function() {
- let is_true = std::env::args().len() == 1;
- let mut countdown = 2;
- if !is_true {
- countdown = 20;
- }
-}
-
-fn use_this_lib_crate() {
- used_from_bin_crate_and_lib_crate_generic_function("used from library used_crate.rs");
- used_with_same_type_from_bin_crate_and_lib_crate_generic_function(
- "used from library used_crate.rs",
- );
- let some_vec = vec![5, 6, 7, 8];
- used_only_from_this_lib_crate_generic_function(some_vec);
- used_only_from_this_lib_crate_generic_function("used ONLY from library used_crate.rs");
-}
diff --git a/tests/run-make/coverage/loop_break_value.rs b/tests/run-make/coverage/loop_break_value.rs
deleted file mode 100644
index dbc4fad7a..000000000
--- a/tests/run-make/coverage/loop_break_value.rs
+++ /dev/null
@@ -1,13 +0,0 @@
-#![allow(unused_assignments, unused_variables)]
-
-fn main() {
- let result
- =
- loop
- {
- break
- 10
- ;
- }
- ;
-}
diff --git a/tests/run-make/coverage/loops_branches.rs b/tests/run-make/coverage/loops_branches.rs
deleted file mode 100644
index 7116ce47f..000000000
--- a/tests/run-make/coverage/loops_branches.rs
+++ /dev/null
@@ -1,61 +0,0 @@
-#![allow(unused_assignments, unused_variables, while_true)]
-
-// This test confirms that (1) unexecuted infinite loops are handled correctly by the
-// InstrumentCoverage MIR pass; and (2) Counter Expressions that subtract from zero can be dropped.
-
-struct DebugTest;
-
-impl std::fmt::Debug for DebugTest {
- fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
- if true {
- if false {
- while true {
- }
- }
- write!(f, "cool")?;
- } else {
- }
-
- for i in 0..10 {
- if true {
- if false {
- while true {}
- }
- write!(f, "cool")?;
- } else {
- }
- }
- Ok(())
- }
-}
-
-struct DisplayTest;
-
-impl std::fmt::Display for DisplayTest {
- fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
- if false {
- } else {
- if false {
- while true {}
- }
- write!(f, "cool")?;
- }
- for i in 0..10 {
- if false {
- } else {
- if false {
- while true {}
- }
- write!(f, "cool")?;
- }
- }
- Ok(())
- }
-}
-
-fn main() {
- let debug_test = DebugTest;
- println!("{:?}", debug_test);
- let display_test = DisplayTest;
- println!("{}", display_test);
-}
diff --git a/tests/run-make/coverage/match_or_pattern.rs b/tests/run-make/coverage/match_or_pattern.rs
deleted file mode 100644
index 4c6a8a9b7..000000000
--- a/tests/run-make/coverage/match_or_pattern.rs
+++ /dev/null
@@ -1,45 +0,0 @@
-#![feature(or_patterns)]
-
-fn main() {
- // Initialize test constants in a way that cannot be determined at compile time, to ensure
- // rustc and LLVM cannot optimize out statements (or coverage counters) downstream from
- // dependent conditions.
- let is_true = std::env::args().len() == 1;
-
- let mut a: u8 = 0;
- let mut b: u8 = 0;
- if is_true {
- a = 2;
- b = 0;
- }
- match (a, b) {
- // Or patterns generate MIR `SwitchInt` with multiple targets to the same `BasicBlock`.
- // This test confirms a fix for Issue #79569.
- (0 | 1, 2 | 3) => {}
- _ => {}
- }
- if is_true {
- a = 0;
- b = 0;
- }
- match (a, b) {
- (0 | 1, 2 | 3) => {}
- _ => {}
- }
- if is_true {
- a = 2;
- b = 2;
- }
- match (a, b) {
- (0 | 1, 2 | 3) => {}
- _ => {}
- }
- if is_true {
- a = 0;
- b = 2;
- }
- match (a, b) {
- (0 | 1, 2 | 3) => {}
- _ => {}
- }
-}
diff --git a/tests/run-make/coverage/nested_loops.rs b/tests/run-make/coverage/nested_loops.rs
deleted file mode 100644
index 4c7c78427..000000000
--- a/tests/run-make/coverage/nested_loops.rs
+++ /dev/null
@@ -1,25 +0,0 @@
-fn main() {
- let is_true = std::env::args().len() == 1;
- let mut countdown = 10;
-
- 'outer: while countdown > 0 {
- let mut a = 100;
- let mut b = 100;
- for _ in 0..50 {
- if a < 30 {
- break;
- }
- a -= 5;
- b -= 5;
- if b < 90 {
- a -= 10;
- if is_true {
- break 'outer;
- } else {
- a -= 2;
- }
- }
- }
- countdown -= 1;
- }
-}
diff --git a/tests/run-make/coverage/no_cov_crate.rs b/tests/run-make/coverage/no_cov_crate.rs
deleted file mode 100644
index 0bfbdda2c..000000000
--- a/tests/run-make/coverage/no_cov_crate.rs
+++ /dev/null
@@ -1,86 +0,0 @@
-// Enables `no_coverage` on the entire crate
-#![feature(no_coverage)]
-
-#[no_coverage]
-fn do_not_add_coverage_1() {
- println!("called but not covered");
-}
-
-fn do_not_add_coverage_2() {
- #![no_coverage]
- println!("called but not covered");
-}
-
-#[no_coverage]
-fn do_not_add_coverage_not_called() {
- println!("not called and not covered");
-}
-
-fn add_coverage_1() {
- println!("called and covered");
-}
-
-fn add_coverage_2() {
- println!("called and covered");
-}
-
-fn add_coverage_not_called() {
- println!("not called but covered");
-}
-
-// FIXME: These test-cases illustrate confusing results of nested functions.
-// See https://github.com/rust-lang/rust/issues/93319
-mod nested_fns {
- #[no_coverage]
- pub fn outer_not_covered(is_true: bool) {
- fn inner(is_true: bool) {
- if is_true {
- println!("called and covered");
- } else {
- println!("absolutely not covered");
- }
- }
- println!("called but not covered");
- inner(is_true);
- }
-
- pub fn outer(is_true: bool) {
- println!("called and covered");
- inner_not_covered(is_true);
-
- #[no_coverage]
- fn inner_not_covered(is_true: bool) {
- if is_true {
- println!("called but not covered");
- } else {
- println!("absolutely not covered");
- }
- }
- }
-
- pub fn outer_both_covered(is_true: bool) {
- println!("called and covered");
- inner(is_true);
-
- fn inner(is_true: bool) {
- if is_true {
- println!("called and covered");
- } else {
- println!("absolutely not covered");
- }
- }
- }
-}
-
-fn main() {
- let is_true = std::env::args().len() == 1;
-
- do_not_add_coverage_1();
- do_not_add_coverage_2();
- add_coverage_1();
- add_coverage_2();
-
- nested_fns::outer_not_covered(is_true);
- nested_fns::outer(is_true);
- nested_fns::outer_both_covered(is_true);
-}
diff --git a/tests/run-make/coverage/overflow.rs b/tests/run-make/coverage/overflow.rs
deleted file mode 100644
index e537b0e95..000000000
--- a/tests/run-make/coverage/overflow.rs
+++ /dev/null
@@ -1,63 +0,0 @@
-#![allow(unused_assignments)]
-// expect-exit-status-101
-
-fn might_overflow(to_add: u32) -> u32 {
- if to_add > 5 {
- println!("this will probably overflow");
- }
- let add_to = u32::MAX - 5;
- println!("does {} + {} overflow?", add_to, to_add);
- let result = to_add + add_to;
- println!("continuing after overflow check");
- result
-}
-
-fn main() -> Result<(),u8> {
- let mut countdown = 10;
- while countdown > 0 {
- if countdown == 1 {
- let result = might_overflow(10);
- println!("Result: {}", result);
- } else if countdown < 5 {
- let result = might_overflow(1);
- println!("Result: {}", result);
- }
- countdown -= 1;
- }
- Ok(())
-}
-
-// Notes:
-// 1. Compare this program and its coverage results to those of the very similar test `assert.rs`,
-// and similar tests `panic_unwind.rs`, abort.rs` and `try_error_result.rs`.
-// 2. This test confirms the coverage generated when a program passes or fails a
-// compiler-generated `TerminatorKind::Assert` (based on an overflow check, in this case).
-// 3. Similar to how the coverage instrumentation handles `TerminatorKind::Call`,
-// compiler-generated assertion failures are assumed to be a symptom of a program bug, not
-// expected behavior. To simplify the coverage graphs and keep instrumented programs as
-// small and fast as possible, `Assert` terminators are assumed to always succeed, and
-// therefore are considered "non-branching" terminators. So, an `Assert` terminator does not
-// get its own coverage counter.
-// 4. After an unhandled panic or failed Assert, coverage results may not always be intuitive.
-// In this test, the final count for the statements after the `if` block in `might_overflow()`
-// is 4, even though the lines after `to_add + add_to` were executed only 3 times. Depending
-// on the MIR graph and the structure of the code, this count could have been 3 (which might
-// have been valid for the overflowed add `+`, but should have been 4 for the lines before
-// the overflow. The reason for this potential uncertainty is, a `CounterKind` is incremented
-// via StatementKind::Counter at the end of the block, but (as in the case in this test),
-// a CounterKind::Expression is always evaluated. In this case, the expression was based on
-// a `Counter` incremented as part of the evaluation of the `if` expression, which was
-// executed, and counted, 4 times, before reaching the overflow add.
-
-// If the program did not overflow, the coverage for `might_overflow()` would look like this:
-//
-// 4| |fn might_overflow(to_add: u32) -> u32 {
-// 5| 4| if to_add > 5 {
-// 6| 0| println!("this will probably overflow");
-// 7| 4| }
-// 8| 4| let add_to = u32::MAX - 5;
-// 9| 4| println!("does {} + {} overflow?", add_to, to_add);
-// 10| 4| let result = to_add + add_to;
-// 11| 4| println!("continuing after overflow check");
-// 12| 4| result
-// 13| 4|}
diff --git a/tests/run-make/coverage/panic_unwind.rs b/tests/run-make/coverage/panic_unwind.rs
deleted file mode 100644
index 03128c2cc..000000000
--- a/tests/run-make/coverage/panic_unwind.rs
+++ /dev/null
@@ -1,31 +0,0 @@
-#![allow(unused_assignments)]
-// expect-exit-status-101
-
-fn might_panic(should_panic: bool) {
- if should_panic {
- println!("panicking...");
- panic!("panics");
- } else {
- println!("Don't Panic");
- }
-}
-
-fn main() -> Result<(), u8> {
- let mut countdown = 10;
- while countdown > 0 {
- if countdown == 1 {
- might_panic(true);
- } else if countdown < 5 {
- might_panic(false);
- }
- countdown -= 1;
- }
- Ok(())
-}
-
-// Notes:
-// 1. Compare this program and its coverage results to those of the similar tests `abort.rs` and
-// `try_error_result.rs`.
-// 2. Since the `panic_unwind.rs` test is allowed to unwind, it is also allowed to execute the
-// normal program exit cleanup, including writing out the current values of the coverage
-// counters.
diff --git a/tests/run-make/coverage/partial_eq.rs b/tests/run-make/coverage/partial_eq.rs
deleted file mode 100644
index 4ceaba9b1..000000000
--- a/tests/run-make/coverage/partial_eq.rs
+++ /dev/null
@@ -1,46 +0,0 @@
-// This test confirms an earlier problem was resolved, supporting the MIR graph generated by the
-// structure of this test.
-
-#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord)]
-pub struct Version {
- major: usize,
- minor: usize,
- patch: usize,
-}
-
-impl Version {
- pub fn new(major: usize, minor: usize, patch: usize) -> Self {
- Self {
- major,
- minor,
- patch,
- }
- }
-}
-
-fn main() {
- let version_3_2_1 = Version::new(3, 2, 1);
- let version_3_3_0 = Version::new(3, 3, 0);
-
- println!("{:?} < {:?} = {}", version_3_2_1, version_3_3_0, version_3_2_1 < version_3_3_0);
-}
-
-/*
-
-This test verifies a bug was fixed that otherwise generated this error:
-
-thread 'rustc' panicked at 'No counters provided the source_hash for function:
- Instance {
- def: Item(WithOptConstParam {
- did: DefId(0:101 ~ autocfg[c44a]::version::{impl#2}::partial_cmp),
- const_param_did: None
- }),
- substs: []
- }'
-The `PartialOrd` derived by `Version` happened to generate a MIR that generated coverage
-without a code region associated with any `Counter`. Code regions were associated with at least
-one expression, which is allowed, but the `function_source_hash` was only passed to the codegen
-(coverage mapgen) phase from a `Counter`s code region. A new method was added to pass the
-`function_source_hash` without a code region, if necessary.
-
-*/
diff --git a/tests/run-make/coverage/simple_loop.rs b/tests/run-make/coverage/simple_loop.rs
deleted file mode 100644
index 6f7f23475..000000000
--- a/tests/run-make/coverage/simple_loop.rs
+++ /dev/null
@@ -1,35 +0,0 @@
-#![allow(unused_assignments)]
-
-fn main() {
- // Initialize test constants in a way that cannot be determined at compile time, to ensure
- // rustc and LLVM cannot optimize out statements (or coverage counters) downstream from
- // dependent conditions.
- let is_true = std::env::args().len() == 1;
-
- let mut countdown = 0;
-
- if
- is_true
- {
- countdown
- =
- 10
- ;
- }
-
- loop
- {
- if
- countdown
- ==
- 0
- {
- break
- ;
- }
- countdown
- -=
- 1
- ;
- }
-}
diff --git a/tests/run-make/coverage/simple_match.rs b/tests/run-make/coverage/simple_match.rs
deleted file mode 100644
index be99e59a8..000000000
--- a/tests/run-make/coverage/simple_match.rs
+++ /dev/null
@@ -1,43 +0,0 @@
-#![allow(unused_assignments, unused_variables)]
-
-fn main() {
- // Initialize test constants in a way that cannot be determined at compile time, to ensure
- // rustc and LLVM cannot optimize out statements (or coverage counters) downstream from
- // dependent conditions.
- let is_true = std::env::args().len() == 1;
-
- let mut countdown = 1;
- if is_true {
- countdown = 0;
- }
-
- for
- _
- in
- 0..2
- {
- let z
- ;
- match
- countdown
- {
- x
- if
- x
- <
- 1
- =>
- {
- z = countdown
- ;
- let y = countdown
- ;
- countdown = 10
- ;
- }
- _
- =>
- {}
- }
- }
-}
diff --git a/tests/run-make/coverage/sort_groups.rs b/tests/run-make/coverage/sort_groups.rs
deleted file mode 100644
index f89f9f3ec..000000000
--- a/tests/run-make/coverage/sort_groups.rs
+++ /dev/null
@@ -1,23 +0,0 @@
-// compile-flags: --edition=2021
-
-// Demonstrate that `sort_subviews.py` can sort instantiation groups into a
-// predictable order, while preserving their heterogeneous contents.
-
-fn main() {
- let cond = std::env::args().len() > 1;
- generic_fn::<()>(cond);
- generic_fn::<&'static str>(!cond);
- if false {
- generic_fn::<char>(cond);
- }
- generic_fn::<i32>(cond);
- other_fn();
-}
-
-fn generic_fn<T>(cond: bool) {
- if cond {
- println!("{}", std::any::type_name::<T>());
- }
-}
-
-fn other_fn() {}
diff --git a/tests/run-make/coverage/test_harness.rs b/tests/run-make/coverage/test_harness.rs
deleted file mode 100644
index 12a755734..000000000
--- a/tests/run-make/coverage/test_harness.rs
+++ /dev/null
@@ -1,10 +0,0 @@
-// Verify that the entry point injected by the test harness doesn't cause
-// weird artifacts in the coverage report (e.g. issue #10749).
-
-// compile-flags: --test
-
-#[allow(dead_code)]
-fn unused() {}
-
-#[test]
-fn my_test() {}
diff --git a/tests/run-make/coverage/tight_inf_loop.rs b/tests/run-make/coverage/tight_inf_loop.rs
deleted file mode 100644
index cef99027a..000000000
--- a/tests/run-make/coverage/tight_inf_loop.rs
+++ /dev/null
@@ -1,5 +0,0 @@
-fn main() {
- if false {
- loop {}
- }
-}
diff --git a/tests/run-make/coverage/try_error_result.rs b/tests/run-make/coverage/try_error_result.rs
deleted file mode 100644
index cd0acf723..000000000
--- a/tests/run-make/coverage/try_error_result.rs
+++ /dev/null
@@ -1,118 +0,0 @@
-#![allow(unused_assignments)]
-// expect-exit-status-1
-
-fn call(return_error: bool) -> Result<(),()> {
- if return_error {
- Err(())
- } else {
- Ok(())
- }
-}
-
-fn test1() -> Result<(),()> {
- let mut
- countdown = 10
- ;
- for
- _
- in
- 0..10
- {
- countdown
- -= 1
- ;
- if
- countdown < 5
- {
- call(/*return_error=*/ true)?;
- call(/*return_error=*/ false)?;
- }
- else
- {
- call(/*return_error=*/ false)?;
- }
- }
- Ok(())
-}
-
-struct Thing1;
-impl Thing1 {
- fn get_thing_2(&self, return_error: bool) -> Result<Thing2,()> {
- if return_error {
- Err(())
- } else {
- Ok(Thing2{})
- }
- }
-}
-
-struct Thing2;
-impl Thing2 {
- fn call(&self, return_error: bool) -> Result<u32,()> {
- if return_error {
- Err(())
- } else {
- Ok(57)
- }
- }
-}
-
-fn test2() -> Result<(),()> {
- let thing1 = Thing1{};
- let mut
- countdown = 10
- ;
- for
- _
- in
- 0..10
- {
- countdown
- -= 1
- ;
- if
- countdown < 5
- {
- thing1.get_thing_2(/*err=*/ false)?.call(/*err=*/ true).expect_err("call should fail");
- thing1
- .
- get_thing_2(/*return_error=*/ false)
- ?
- .
- call(/*return_error=*/ true)
- .
- expect_err(
- "call should fail"
- );
- let val = thing1.get_thing_2(/*return_error=*/ true)?.call(/*return_error=*/ true)?;
- assert_eq!(val, 57);
- let val = thing1.get_thing_2(/*return_error=*/ true)?.call(/*return_error=*/ false)?;
- assert_eq!(val, 57);
- }
- else
- {
- let val = thing1.get_thing_2(/*return_error=*/ false)?.call(/*return_error=*/ false)?;
- assert_eq!(val, 57);
- let val = thing1
- .get_thing_2(/*return_error=*/ false)?
- .call(/*return_error=*/ false)?;
- assert_eq!(val, 57);
- let val = thing1
- .get_thing_2(/*return_error=*/ false)
- ?
- .call(/*return_error=*/ false)
- ?
- ;
- assert_eq!(val, 57);
- }
- }
- Ok(())
-}
-
-fn main() -> Result<(),()> {
- test1().expect_err("test1 should fail");
- test2()
- ?
- ;
- Ok(())
-}
diff --git a/tests/run-make/coverage/unused.rs b/tests/run-make/coverage/unused.rs
deleted file mode 100644
index fb6113eb0..000000000
--- a/tests/run-make/coverage/unused.rs
+++ /dev/null
@@ -1,39 +0,0 @@
-fn foo<T>(x: T) {
- let mut i = 0;
- while i < 10 {
- i != 0 || i != 0;
- i += 1;
- }
-}
-
-fn unused_template_func<T>(x: T) {
- let mut i = 0;
- while i < 10 {
- i != 0 || i != 0;
- i += 1;
- }
-}
-
-fn unused_func(mut a: u32) {
- if a != 0 {
- a += 1;
- }
-}
-
-fn unused_func2(mut a: u32) {
- if a != 0 {
- a += 1;
- }
-}
-
-fn unused_func3(mut a: u32) {
- if a != 0 {
- a += 1;
- }
-}
-
-fn main() -> Result<(), u8> {
- foo::<u32>(0);
- foo::<f32>(0.0);
- Ok(())
-}
diff --git a/tests/run-make/coverage/unused_mod.rs b/tests/run-make/coverage/unused_mod.rs
deleted file mode 100644
index 679b4e531..000000000
--- a/tests/run-make/coverage/unused_mod.rs
+++ /dev/null
@@ -1,6 +0,0 @@
-#[path = "lib/unused_mod_helper.rs"]
-mod unused_module;
-
-fn main() {
- println!("hello world!");
-}
diff --git a/tests/run-make/coverage/uses_crate.rs b/tests/run-make/coverage/uses_crate.rs
deleted file mode 100644
index 1ee8037a1..000000000
--- a/tests/run-make/coverage/uses_crate.rs
+++ /dev/null
@@ -1,15 +0,0 @@
-// FIXME #110395
-// ignore-llvm-cov-show-diffs
-
-#![allow(unused_assignments, unused_variables)]
-// compile-flags: -C opt-level=3 # validates coverage now works with optimizations
-extern crate used_crate;
-
-fn main() {
- used_crate::used_function();
- let some_vec = vec![1, 2, 3, 4];
- used_crate::used_only_from_bin_crate_generic_function(&some_vec);
- used_crate::used_only_from_bin_crate_generic_function("used from bin uses_crate.rs");
- used_crate::used_from_bin_crate_and_lib_crate_generic_function(some_vec);
- used_crate::used_with_same_type_from_bin_crate_and_lib_crate_generic_function("interesting?");
-}
diff --git a/tests/run-make/coverage/uses_inline_crate.rs b/tests/run-make/coverage/uses_inline_crate.rs
deleted file mode 100644
index f7aff3c3f..000000000
--- a/tests/run-make/coverage/uses_inline_crate.rs
+++ /dev/null
@@ -1,20 +0,0 @@
-// FIXME #110395
-// ignore-llvm-cov-show-diffs
-
-#![allow(unused_assignments, unused_variables)]
-
-// compile-flags: -C opt-level=3 # validates coverage now works with optimizations
-
-extern crate used_inline_crate;
-
-fn main() {
- used_inline_crate::used_function();
- used_inline_crate::used_inline_function();
- let some_vec = vec![1, 2, 3, 4];
- used_inline_crate::used_only_from_bin_crate_generic_function(&some_vec);
- used_inline_crate::used_only_from_bin_crate_generic_function("used from bin uses_crate.rs");
- used_inline_crate::used_from_bin_crate_and_lib_crate_generic_function(some_vec);
- used_inline_crate::used_with_same_type_from_bin_crate_and_lib_crate_generic_function(
- "interesting?",
- );
-}
diff --git a/tests/run-make/coverage/while.rs b/tests/run-make/coverage/while.rs
deleted file mode 100644
index 781b90b35..000000000
--- a/tests/run-make/coverage/while.rs
+++ /dev/null
@@ -1,5 +0,0 @@
-fn main() {
- let num = 9;
- while num >= 10 {
- }
-}
diff --git a/tests/run-make/coverage/while_early_ret.rs b/tests/run-make/coverage/while_early_ret.rs
deleted file mode 100644
index 1fcea9c85..000000000
--- a/tests/run-make/coverage/while_early_ret.rs
+++ /dev/null
@@ -1,42 +0,0 @@
-#![allow(unused_assignments)]
-// expect-exit-status-1
-
-fn main() -> Result<(),u8> {
- let mut countdown = 10;
- while
- countdown
- >
- 0
- {
- if
- countdown
- <
- 5
- {
- return
- if
- countdown
- >
- 8
- {
- Ok(())
- }
- else
- {
- Err(1)
- }
- ;
- }
- countdown
- -=
- 1
- ;
- }
- Ok(())
-}
-
-// ISSUE(77553): Originally, this test had `Err(1)` on line 22 (instead of `Ok(())`) and
-// `std::process::exit(2)` on line 26 (instead of `Err(1)`); and this worked as expected on Linux
-// and MacOS. But on Windows (MSVC, at least), the call to `std::process::exit()` exits the program
-// without saving the InstrProf coverage counters. The use of `std::process:exit()` is not critical
-// to the coverage test for early returns, but this is a limitation that should be fixed.
diff --git a/tests/run-make/coverage/yield.rs b/tests/run-make/coverage/yield.rs
deleted file mode 100644
index ff7616656..000000000
--- a/tests/run-make/coverage/yield.rs
+++ /dev/null
@@ -1,37 +0,0 @@
-#![feature(generators, generator_trait)]
-#![allow(unused_assignments)]
-
-use std::ops::{Generator, GeneratorState};
-use std::pin::Pin;
-
-fn main() {
- let mut generator = || {
- yield 1;
- return "foo"
- };
-
- match Pin::new(&mut generator).resume(()) {
- GeneratorState::Yielded(1) => {}
- _ => panic!("unexpected value from resume"),
- }
- match Pin::new(&mut generator).resume(()) {
- GeneratorState::Complete("foo") => {}
- _ => panic!("unexpected value from resume"),
- }
-
- let mut generator = || {
- yield 1;
- yield 2;
- yield 3;
- return "foo"
- };
-
- match Pin::new(&mut generator).resume(()) {
- GeneratorState::Yielded(1) => {}
- _ => panic!("unexpected value from resume"),
- }
- match Pin::new(&mut generator).resume(()) {
- GeneratorState::Yielded(2) => {}
- _ => panic!("unexpected value from resume"),
- }
-}
diff --git a/tests/run-make/crate-hash-rustc-version/Makefile b/tests/run-make/crate-hash-rustc-version/Makefile
index f1d2a3604..6bf504bf0 100644
--- a/tests/run-make/crate-hash-rustc-version/Makefile
+++ b/tests/run-make/crate-hash-rustc-version/Makefile
@@ -4,7 +4,7 @@ include ../tools.mk
# Ensure that crates compiled with different rustc versions cannot
# be dynamically linked.
-FLAGS := -Cprefer-dynamic -Zsymbol-mangling-version=v0
+FLAGS := -Cprefer-dynamic -Csymbol-mangling-version=v0
UNAME := $(shell uname)
ifeq ($(UNAME),Linux)
EXT=".so"
diff --git a/tests/run-make/doctests-keep-binaries/Makefile b/tests/run-make/doctests-keep-binaries/Makefile
index 6254e93d3..2c647851a 100644
--- a/tests/run-make/doctests-keep-binaries/Makefile
+++ b/tests/run-make/doctests-keep-binaries/Makefile
@@ -3,7 +3,9 @@ include ../tools.mk
# Check that valid binaries are persisted by running them, regardless of whether the --run or --no-run option is used.
-all: run no_run
+MY_SRC_DIR := ${CURDIR}
+
+all: run no_run test_run_directory
run:
mkdir -p $(TMPDIR)/doctests
@@ -20,3 +22,12 @@ no_run:
$(TMPDIR)/doctests/t_rs_2_0/rust_out
$(TMPDIR)/doctests/t_rs_8_0/rust_out
rm -rf $(TMPDIR)/doctests
+
+# Behavior with --test-run-directory with relative paths.
+test_run_directory:
+ mkdir -p $(TMPDIR)/doctests
+ mkdir -p $(TMPDIR)/rundir
+ $(RUSTC) --crate-type rlib t.rs
+ ( cd $(TMPDIR); \
+ $(RUSTDOC) -Zunstable-options --test --persist-doctests doctests --test-run-directory rundir --extern t=libt.rlib $(MY_SRC_DIR)/t.rs )
+ rm -rf $(TMPDIR)/doctests $(TMPDIR)/rundir
diff --git a/tests/run-make/doctests-runtool/Makefile b/tests/run-make/doctests-runtool/Makefile
new file mode 100644
index 000000000..7d5df1e30
--- /dev/null
+++ b/tests/run-make/doctests-runtool/Makefile
@@ -0,0 +1,20 @@
+# ignore-cross-compile
+include ../tools.mk
+
+# Tests behavior of rustdoc --runtool
+
+MY_SRC_DIR := ${CURDIR}
+
+all: with_test_run_directory
+
+# Behavior with --runtool with relative paths and --test-run-directory.
+with_test_run_directory:
+ mkdir -p $(TMPDIR)/rundir
+ mkdir -p $(TMPDIR)/runtool
+ $(RUSTC) --crate-type rlib t.rs
+ $(RUSTC) runtool.rs -o $(TMPDIR)/runtool/runtool
+ ( cd $(TMPDIR); \
+ $(RUSTDOC) -Zunstable-options --test --test-run-directory rundir \
+ --runtool runtool/runtool --extern t=libt.rlib $(MY_SRC_DIR)/t.rs \
+ )
+ rm -rf $(TMPDIR)/rundir $(TMPDIR)/runtool
diff --git a/tests/run-make/doctests-runtool/runtool.rs b/tests/run-make/doctests-runtool/runtool.rs
new file mode 100644
index 000000000..f5e3afdf2
--- /dev/null
+++ b/tests/run-make/doctests-runtool/runtool.rs
@@ -0,0 +1,3 @@
+fn main() {
+ eprintln!("{:?}", std::env::args().collect::<Vec<_>>());
+}
diff --git a/tests/run-make/doctests-runtool/t.rs b/tests/run-make/doctests-runtool/t.rs
new file mode 100644
index 000000000..c38cf0a0b
--- /dev/null
+++ b/tests/run-make/doctests-runtool/t.rs
@@ -0,0 +1,11 @@
+/// Fungle the foople.
+/// ```
+/// t::foople();
+/// ```
+pub fn foople() {}
+
+/// Flomble the florp
+/// ```
+/// t::florp();
+/// ```
+pub fn florp() {}
diff --git a/tests/run-make/dump-ice-to-disk/Makefile b/tests/run-make/dump-ice-to-disk/Makefile
new file mode 100644
index 000000000..23006fc09
--- /dev/null
+++ b/tests/run-make/dump-ice-to-disk/Makefile
@@ -0,0 +1,10 @@
+include ../tools.mk
+
+# ignore-windows
+
+export RUSTC := $(RUSTC_ORIGINAL)
+export LD_LIBRARY_PATH := $(HOST_RPATH_DIR)
+export TMPDIR := $(TMPDIR)
+
+all:
+ bash check.sh
diff --git a/tests/run-make/dump-ice-to-disk/check.sh b/tests/run-make/dump-ice-to-disk/check.sh
new file mode 100644
index 000000000..ff6e4be35
--- /dev/null
+++ b/tests/run-make/dump-ice-to-disk/check.sh
@@ -0,0 +1,64 @@
+#!/bin/sh
+
+# Default nightly behavior (write ICE to current directory)
+# FIXME(estebank): these are failing on CI, but passing locally.
+# $RUSTC src/lib.rs -Z treat-err-as-bug=1 1>$TMPDIR/rust-test-default.log 2>&1
+# default=$(cat ./rustc-ice-*.txt | wc -l)
+# rm ./rustc-ice-*.txt
+
+# Explicit directory set
+export RUSTC_ICE=$TMPDIR
+$RUSTC src/lib.rs -Z treat-err-as-bug=1 1>$TMPDIR/rust-test-default-set.log 2>&1
+default_set=$(cat $TMPDIR/rustc-ice-*.txt | wc -l)
+content=$(cat $TMPDIR/rustc-ice-*.txt)
+# Ensure that the ICE dump path doesn't contain `:` because they cause problems on Windows
+windows_safe=$(echo rustc-ice-*.txt | grep ':')
+if [ ! -z "$windows_safe" ]; then
+ exit 1
+fi
+
+rm $TMPDIR/rustc-ice-*.txt
+RUST_BACKTRACE=short $RUSTC src/lib.rs -Z treat-err-as-bug=1 1>$TMPDIR/rust-test-short.log 2>&1
+short=$(cat $TMPDIR/rustc-ice-*.txt | wc -l)
+rm $TMPDIR/rustc-ice-*.txt
+RUST_BACKTRACE=full $RUSTC src/lib.rs -Z treat-err-as-bug=1 1>$TMPDIR/rust-test-full.log 2>&1
+full=$(cat $TMPDIR/rustc-ice-*.txt | wc -l)
+rm $TMPDIR/rustc-ice-*.txt
+
+# Explicitly disabling ICE dump
+export RUSTC_ICE=0
+$RUSTC src/lib.rs -Z treat-err-as-bug=1 1>$TMPDIR/rust-test-disabled.log 2>&1
+should_be_empty_tmp=$(ls -l $TMPDIR/rustc-ice-*.txt 2>/dev/null | wc -l)
+should_be_empty_dot=$(ls -l ./rustc-ice-*.txt 2>/dev/null | wc -l)
+
+echo "#### ICE Dump content:"
+echo $content
+echo "#### default length:"
+echo $default
+echo "#### short length:"
+echo $short
+echo "#### default_set length:"
+echo $default_set
+echo "#### full length:"
+echo $full
+echo "#### should_be_empty_dot length:"
+echo $should_be_empty_dot
+echo "#### should_be_empty_tmp length:"
+echo $should_be_empty_tmp
+
+## Verify that a the ICE dump file is created in the appropriate directories, that
+## their lengths are the same regardless of other backtrace configuration options,
+## that the file is not created when asked to (RUSTC_ICE=0) and that the file
+## contains at least part of the expected content.
+if [ $short -eq $default_set ] &&
+ #[ $default -eq $short ] &&
+ [ $default_set -eq $full ] &&
+ [[ $content == *"thread 'rustc' panicked at "* ]] &&
+ [[ $content == *"stack backtrace:"* ]] &&
+ #[ $default -gt 0 ] &&
+ [ $should_be_empty_dot -eq 0 ] &&
+ [ $should_be_empty_tmp -eq 0 ]; then
+ exit 0
+else
+ exit 1
+fi
diff --git a/tests/run-make/dump-ice-to-disk/src/lib.rs b/tests/run-make/dump-ice-to-disk/src/lib.rs
new file mode 100644
index 000000000..b23b7f830
--- /dev/null
+++ b/tests/run-make/dump-ice-to-disk/src/lib.rs
@@ -0,0 +1,7 @@
+fn func(s: &str) {
+ println!("{}", s);
+}
+
+fn main() {
+ func(1);
+}
diff --git a/tests/run-make/emit-path-unhashed/Makefile b/tests/run-make/emit-path-unhashed/Makefile
index 74047fe5f..611f85781 100644
--- a/tests/run-make/emit-path-unhashed/Makefile
+++ b/tests/run-make/emit-path-unhashed/Makefile
@@ -5,10 +5,10 @@ OUT=$(TMPDIR)/emit
# --emit KIND=PATH should not affect crate hash vs --emit KIND
all: $(OUT)/a/libfoo.rlib $(OUT)/b/libfoo.rlib $(OUT)/c/libfoo.rlib \
$(TMPDIR)/libfoo.rlib
- $(RUSTC) -Zls $(TMPDIR)/libfoo.rlib > $(TMPDIR)/base.txt
- $(RUSTC) -Zls $(OUT)/a/libfoo.rlib > $(TMPDIR)/a.txt
- $(RUSTC) -Zls $(OUT)/b/libfoo.rlib > $(TMPDIR)/b.txt
- $(RUSTC) -Zls $(OUT)/c/libfoo.rlib > $(TMPDIR)/c.txt
+ $(RUSTC) -Zls=root $(TMPDIR)/libfoo.rlib > $(TMPDIR)/base.txt
+ $(RUSTC) -Zls=root $(OUT)/a/libfoo.rlib > $(TMPDIR)/a.txt
+ $(RUSTC) -Zls=root $(OUT)/b/libfoo.rlib > $(TMPDIR)/b.txt
+ $(RUSTC) -Zls=root $(OUT)/c/libfoo.rlib > $(TMPDIR)/c.txt
diff $(TMPDIR)/base.txt $(TMPDIR)/a.txt
diff $(TMPDIR)/base.txt $(TMPDIR)/b.txt
diff --git a/tests/run-make/emit-stack-sizes/foo.rs b/tests/run-make/emit-stack-sizes/foo.rs
index ee51ae328..fd0b51205 100644
--- a/tests/run-make/emit-stack-sizes/foo.rs
+++ b/tests/run-make/emit-stack-sizes/foo.rs
@@ -1,3 +1,4 @@
#![crate_type = "lib"]
+#[inline(never)]
pub fn foo() {}
diff --git a/tests/run-make/emit-to-stdout/Makefile b/tests/run-make/emit-to-stdout/Makefile
new file mode 100644
index 000000000..80e9b6a4d
--- /dev/null
+++ b/tests/run-make/emit-to-stdout/Makefile
@@ -0,0 +1,51 @@
+include ../tools.mk
+
+SRC=test.rs
+OUT=$(TMPDIR)/out
+
+all: asm llvm-ir dep-info mir llvm-bc obj metadata link multiple-types multiple-types-option-o
+
+asm: $(OUT)
+ $(RUSTC) --emit asm=$(OUT)/$@ $(SRC)
+ $(RUSTC) --emit asm=- $(SRC) | diff - $(OUT)/$@
+llvm-ir: $(OUT)
+ $(RUSTC) --emit llvm-ir=$(OUT)/$@ $(SRC)
+ $(RUSTC) --emit llvm-ir=- $(SRC) | diff - $(OUT)/$@
+dep-info: $(OUT)
+ $(RUSTC) -Z dep-info-omit-d-target=yes --emit dep-info=$(OUT)/$@ $(SRC)
+ $(RUSTC) --emit dep-info=- $(SRC) | diff - $(OUT)/$@
+mir: $(OUT)
+ $(RUSTC) --emit mir=$(OUT)/$@ $(SRC)
+ $(RUSTC) --emit mir=- $(SRC) | diff - $(OUT)/$@
+
+llvm-bc: $(OUT)
+ $(RUSTC) --emit llvm-bc=- $(SRC) 1>/dev/ptmx 2>$(OUT)/$@ || true
+ diff $(OUT)/$@ emit-llvm-bc.stderr
+obj: $(OUT)
+ $(RUSTC) --emit obj=- $(SRC) 1>/dev/ptmx 2>$(OUT)/$@ || true
+ diff $(OUT)/$@ emit-obj.stderr
+
+# For metadata output, a temporary directory will be created to hold the temporary
+# metadata file. But when output is stdout, the temporary directory will be located
+# in the same place as $(SRC), which is mounted as read-only in the tests. Thus as
+# a workaround, $(SRC) is copied to the test output directory $(OUT) and we compile
+# it there.
+metadata: $(OUT)
+ cp $(SRC) $(OUT)
+ (cd $(OUT); $(RUSTC) --emit metadata=- $(SRC) 1>/dev/ptmx 2>$(OUT)/$@ || true)
+ diff $(OUT)/$@ emit-metadata.stderr
+
+link: $(OUT)
+ $(RUSTC) --emit link=- $(SRC) 1>/dev/ptmx 2>$(OUT)/$@ || true
+ diff $(OUT)/$@ emit-link.stderr
+
+multiple-types: $(OUT)
+ $(RUSTC) --emit asm=- --emit llvm-ir=- --emit dep-info=- --emit mir=- $(SRC) 2>$(OUT)/$@ || true
+ diff $(OUT)/$@ emit-multiple-types.stderr
+
+multiple-types-option-o: $(OUT)
+ $(RUSTC) -o - --emit asm,llvm-ir,dep-info,mir $(SRC) 2>$(OUT)/$@ || true
+ diff $(OUT)/$@ emit-multiple-types.stderr
+
+$(OUT):
+ mkdir -p $(OUT)
diff --git a/tests/run-make/emit-to-stdout/emit-link.stderr b/tests/run-make/emit-to-stdout/emit-link.stderr
new file mode 100644
index 000000000..0553b22a4
--- /dev/null
+++ b/tests/run-make/emit-to-stdout/emit-link.stderr
@@ -0,0 +1,4 @@
+error: option `-o` or `--emit` is used to write binary output type `link` to stdout, but stdout is a tty
+
+error: aborting due to 1 previous error
+
diff --git a/tests/run-make/emit-to-stdout/emit-llvm-bc.stderr b/tests/run-make/emit-to-stdout/emit-llvm-bc.stderr
new file mode 100644
index 000000000..a50148f9e
--- /dev/null
+++ b/tests/run-make/emit-to-stdout/emit-llvm-bc.stderr
@@ -0,0 +1,4 @@
+error: option `-o` or `--emit` is used to write binary output type `llvm-bc` to stdout, but stdout is a tty
+
+error: aborting due to 1 previous error
+
diff --git a/tests/run-make/emit-to-stdout/emit-metadata.stderr b/tests/run-make/emit-to-stdout/emit-metadata.stderr
new file mode 100644
index 000000000..27ad5d529
--- /dev/null
+++ b/tests/run-make/emit-to-stdout/emit-metadata.stderr
@@ -0,0 +1,4 @@
+error: option `-o` or `--emit` is used to write binary output type `metadata` to stdout, but stdout is a tty
+
+error: aborting due to 1 previous error
+
diff --git a/tests/run-make/emit-to-stdout/emit-multiple-types.stderr b/tests/run-make/emit-to-stdout/emit-multiple-types.stderr
new file mode 100644
index 000000000..4f74cb840
--- /dev/null
+++ b/tests/run-make/emit-to-stdout/emit-multiple-types.stderr
@@ -0,0 +1,4 @@
+error: can't use option `-o` or `--emit` to write multiple output types to stdout
+
+error: aborting due to 1 previous error
+
diff --git a/tests/run-make/emit-to-stdout/emit-obj.stderr b/tests/run-make/emit-to-stdout/emit-obj.stderr
new file mode 100644
index 000000000..9bbcea010
--- /dev/null
+++ b/tests/run-make/emit-to-stdout/emit-obj.stderr
@@ -0,0 +1,4 @@
+error: option `-o` or `--emit` is used to write binary output type `obj` to stdout, but stdout is a tty
+
+error: aborting due to 1 previous error
+
diff --git a/tests/run-make/emit-to-stdout/test.rs b/tests/run-make/emit-to-stdout/test.rs
new file mode 100644
index 000000000..c1bfaa6ca
--- /dev/null
+++ b/tests/run-make/emit-to-stdout/test.rs
@@ -0,0 +1 @@
+#![crate_type = "rlib"]
diff --git a/tests/run-make/exit-code/Makefile b/tests/run-make/exit-code/Makefile
index 6458b7168..155e5cd11 100644
--- a/tests/run-make/exit-code/Makefile
+++ b/tests/run-make/exit-code/Makefile
@@ -5,7 +5,7 @@ all:
$(RUSTC) success.rs; [ $$? -eq 0 ]
$(RUSTC) --invalid-arg-foo; [ $$? -eq 1 ]
$(RUSTC) compile-error.rs; [ $$? -eq 1 ]
- $(RUSTC) -Ztreat-err-as-bug compile-error.rs; [ $$? -eq 101 ]
+ RUSTC_ICE=0 $(RUSTC) -Ztreat-err-as-bug compile-error.rs; [ $$? -eq 101 ]
$(RUSTDOC) -o $(TMPDIR)/exit-code success.rs; [ $$? -eq 0 ]
$(RUSTDOC) --invalid-arg-foo; [ $$? -eq 1 ]
$(RUSTDOC) compile-error.rs; [ $$? -eq 1 ]
diff --git a/tests/run-make/extern-flag-pathless/Makefile b/tests/run-make/extern-flag-pathless/Makefile
index 701bfcd28..36b374e0d 100644
--- a/tests/run-make/extern-flag-pathless/Makefile
+++ b/tests/run-make/extern-flag-pathless/Makefile
@@ -3,17 +3,32 @@ include ../tools.mk
# Test mixing pathless --extern with paths.
+# Test for static linking by checking that the binary runs if the dylib
+# is removed and test for dynamic linking by checking that the binary
+# fails to run if the dylib is removed.
+
all:
- $(RUSTC) bar-static.rs --crate-name=bar --crate-type=rlib
- $(RUSTC) bar-dynamic.rs --crate-name=bar --crate-type=dylib -C prefer-dynamic
+ $(RUSTC) bar.rs --crate-type=rlib --crate-type=dylib -Cprefer-dynamic
+
# rlib preferred over dylib
$(RUSTC) foo.rs --extern bar
- $(call RUN,foo) | $(CGREP) 'static'
+ mv $(call DYLIB,bar) $(TMPDIR)/bar.tmp
+ $(call RUN,foo)
+ mv $(TMPDIR)/bar.tmp $(call DYLIB,bar)
+
$(RUSTC) foo.rs --extern bar=$(TMPDIR)/libbar.rlib --extern bar
- $(call RUN,foo) | $(CGREP) 'static'
+ mv $(call DYLIB,bar) $(TMPDIR)/bar.tmp
+ $(call RUN,foo)
+ mv $(TMPDIR)/bar.tmp $(call DYLIB,bar)
+
# explicit --extern overrides pathless
$(RUSTC) foo.rs --extern bar=$(call DYLIB,bar) --extern bar
- $(call RUN,foo) | $(CGREP) 'dynamic'
+ mv $(call DYLIB,bar) $(TMPDIR)/bar.tmp
+ $(call FAIL,foo)
+ mv $(TMPDIR)/bar.tmp $(call DYLIB,bar)
+
# prefer-dynamic does what it says
$(RUSTC) foo.rs --extern bar -C prefer-dynamic
- $(call RUN,foo) | $(CGREP) 'dynamic'
+ mv $(call DYLIB,bar) $(TMPDIR)/bar.tmp
+ $(call FAIL,foo)
+ mv $(TMPDIR)/bar.tmp $(call DYLIB,bar)
diff --git a/tests/run-make/extern-flag-pathless/bar-dynamic.rs b/tests/run-make/extern-flag-pathless/bar-dynamic.rs
deleted file mode 100644
index e2d68d517..000000000
--- a/tests/run-make/extern-flag-pathless/bar-dynamic.rs
+++ /dev/null
@@ -1,3 +0,0 @@
-pub fn f() {
- println!("dynamic");
-}
diff --git a/tests/run-make/extern-flag-pathless/bar-static.rs b/tests/run-make/extern-flag-pathless/bar-static.rs
deleted file mode 100644
index 240d8bde4..000000000
--- a/tests/run-make/extern-flag-pathless/bar-static.rs
+++ /dev/null
@@ -1,3 +0,0 @@
-pub fn f() {
- println!("static");
-}
diff --git a/tests/run-make/extern-flag-pathless/bar.rs b/tests/run-make/extern-flag-pathless/bar.rs
new file mode 100644
index 000000000..cdc6c27d8
--- /dev/null
+++ b/tests/run-make/extern-flag-pathless/bar.rs
@@ -0,0 +1 @@
+pub fn f() {}
diff --git a/tests/run-make/extern-fn-explicit-align/Makefile b/tests/run-make/extern-fn-explicit-align/Makefile
new file mode 100644
index 000000000..3cbbf3839
--- /dev/null
+++ b/tests/run-make/extern-fn-explicit-align/Makefile
@@ -0,0 +1,6 @@
+# ignore-cross-compile
+include ../tools.mk
+
+all: $(call NATIVE_STATICLIB,test)
+ $(RUSTC) test.rs
+ $(call RUN,test) || exit 1
diff --git a/tests/run-make/extern-fn-explicit-align/test.c b/tests/run-make/extern-fn-explicit-align/test.c
new file mode 100644
index 000000000..a3db3442a
--- /dev/null
+++ b/tests/run-make/extern-fn-explicit-align/test.c
@@ -0,0 +1,93 @@
+#include <assert.h>
+#include <stdbool.h>
+#include <stdint.h>
+#include <string.h>
+
+struct BoolAndU32
+{
+ bool a;
+ uint32_t b;
+};
+
+#ifdef _MSC_VER
+__declspec(align(16))
+struct TwoU64s
+{
+ uint64_t a;
+ uint64_t b;
+};
+#else
+struct __attribute__((aligned(16))) TwoU64s
+{
+ uint64_t a;
+ uint64_t b;
+};
+#endif
+
+struct WrappedU64s
+{
+ struct TwoU64s a;
+};
+
+#ifdef _MSC_VER
+__declspec(align(1))
+struct LowerAlign
+{
+ uint64_t a;
+ uint64_t b;
+};
+#else
+struct __attribute__((aligned(1))) LowerAlign
+{
+ uint64_t a;
+ uint64_t b;
+};
+#endif
+
+#pragma pack(push, 1)
+struct Packed
+{
+ uint64_t a;
+ uint64_t b;
+};
+#pragma pack(pop)
+
+int32_t many_args(
+ void *a,
+ void *b,
+ const char *c,
+ uint64_t d,
+ bool e,
+ struct BoolAndU32 f,
+ void *g,
+ struct TwoU64s h,
+ void *i,
+ struct WrappedU64s j,
+ void *k,
+ struct LowerAlign l,
+ void *m,
+ struct Packed n,
+ const char *o)
+{
+ assert(!a);
+ assert(!b);
+ assert(!c);
+ assert(d == 42);
+ assert(e);
+ assert(f.a);
+ assert(f.b == 1337);
+ assert(!g);
+ assert(h.a == 1);
+ assert(h.b == 2);
+ assert(!i);
+ assert(j.a.a == 3);
+ assert(j.a.b == 4);
+ assert(!k);
+ assert(l.a == 5);
+ assert(l.b == 6);
+ assert(!m);
+ assert(n.a == 7);
+ assert(n.b == 8);
+ assert(strcmp(o, "Hello world") == 0);
+ return 0;
+}
diff --git a/tests/run-make/extern-fn-explicit-align/test.rs b/tests/run-make/extern-fn-explicit-align/test.rs
new file mode 100644
index 000000000..846622de3
--- /dev/null
+++ b/tests/run-make/extern-fn-explicit-align/test.rs
@@ -0,0 +1,89 @@
+// Issue #80127: Passing structs via FFI should work with explicit alignment.
+
+use std::ffi::{CStr, c_char};
+use std::ptr::null_mut;
+
+#[repr(C)]
+pub struct BoolAndU32 {
+ pub a: bool,
+ pub b: u32,
+}
+
+#[repr(C)]
+#[repr(align(16))]
+pub struct TwoU64s {
+ pub a: u64,
+ pub b: u64,
+}
+
+#[repr(C)]
+pub struct WrappedU64s {
+ pub a: TwoU64s
+}
+
+#[repr(C)]
+// Even though requesting align 1 can never change the alignment, it still affects the ABI
+// on some platforms like i686-windows.
+#[repr(align(1))]
+pub struct LowerAlign {
+ pub a: u64,
+ pub b: u64,
+}
+
+#[repr(C)]
+#[repr(packed)]
+pub struct Packed {
+ pub a: u64,
+ pub b: u64,
+}
+
+#[link(name = "test", kind = "static")]
+extern "C" {
+ fn many_args(
+ a: *mut (),
+ b: *mut (),
+ c: *const c_char,
+ d: u64,
+ e: bool,
+ f: BoolAndU32,
+ g: *mut (),
+ h: TwoU64s,
+ i: *mut (),
+ j: WrappedU64s,
+ k: *mut (),
+ l: LowerAlign,
+ m: *mut (),
+ n: Packed,
+ o: *const c_char,
+ ) -> i32;
+}
+
+const STRING: &CStr = unsafe { CStr::from_bytes_with_nul_unchecked(b"Hello world\0") };
+
+fn main() {
+ let bool_and_u32 = BoolAndU32 { a: true, b: 1337 };
+ let two_u64s = TwoU64s { a: 1, b: 2 };
+ let wrapped = WrappedU64s { a: TwoU64s { a: 3, b: 4 } };
+ let lower = LowerAlign { a: 5, b: 6 };
+ let packed = Packed { a: 7, b: 8 };
+ let string = STRING;
+ unsafe {
+ many_args(
+ null_mut(),
+ null_mut(),
+ null_mut(),
+ 42,
+ true,
+ bool_and_u32,
+ null_mut(),
+ two_u64s,
+ null_mut(),
+ wrapped,
+ null_mut(),
+ lower,
+ null_mut(),
+ packed,
+ string.as_ptr(),
+ );
+ }
+}
diff --git a/tests/run-make/extern-fn-struct-passing-abi/test.c b/tests/run-make/extern-fn-struct-passing-abi/test.c
index 136b07129..2cff776d8 100644
--- a/tests/run-make/extern-fn-struct-passing-abi/test.c
+++ b/tests/run-make/extern-fn-struct-passing-abi/test.c
@@ -28,6 +28,14 @@ struct Huge {
int32_t e;
};
+struct Huge64 {
+ int64_t a;
+ int64_t b;
+ int64_t c;
+ int64_t d;
+ int64_t e;
+};
+
struct FloatPoint {
double x;
double y;
@@ -152,6 +160,21 @@ void byval_rect_with_many_huge(struct Huge a, struct Huge b, struct Huge c,
assert(g.d == 420);
}
+// System V x86_64 ABI:
+// a, b, d, e, f should be byval pointer (on the stack)
+// g passed via register (fixes #41375)
+//
+// i686-windows ABI:
+// a, b, d, e, f, g should be byval pointer
+void byval_rect_with_many_huge64(struct Huge64 a, struct Huge64 b, struct Huge64 c,
+ struct Huge64 d, struct Huge64 e, struct Huge64 f,
+ struct Rect g) {
+ assert(g.a == 1234);
+ assert(g.b == 4567);
+ assert(g.c == 7890);
+ assert(g.d == 4209);
+}
+
// System V x86_64 & Win64 ABI:
// a, b should be in registers
// s should be split across 2 integer registers
@@ -279,6 +302,19 @@ struct Huge huge_struct(struct Huge s) {
return s;
}
+// System V x86_64 & i686-windows ABI:
+// s should be byval pointer
+// return should in a hidden sret pointer
+struct Huge64 huge64_struct(struct Huge64 s) {
+ assert(s.a == 1234);
+ assert(s.b == 1335);
+ assert(s.c == 1436);
+ assert(s.d == 1537);
+ assert(s.e == 1638);
+
+ return s;
+}
+
// System V x86_64 ABI:
// p should be in registers
// return should be in registers
diff --git a/tests/run-make/extern-fn-struct-passing-abi/test.rs b/tests/run-make/extern-fn-struct-passing-abi/test.rs
index afe0f52ef..99e079f98 100644
--- a/tests/run-make/extern-fn-struct-passing-abi/test.rs
+++ b/tests/run-make/extern-fn-struct-passing-abi/test.rs
@@ -38,6 +38,16 @@ struct Huge {
#[derive(Clone, Copy, Debug, PartialEq)]
#[repr(C)]
+struct Huge64 {
+ a: i64,
+ b: i64,
+ c: i64,
+ d: i64,
+ e: i64,
+}
+
+#[derive(Clone, Copy, Debug, PartialEq)]
+#[repr(C)]
struct FloatPoint {
x: f64,
y: f64,
@@ -79,6 +89,12 @@ extern "C" {
fn byval_rect_with_many_huge(a: Huge, b: Huge, c: Huge, d: Huge, e: Huge, f: Huge, g: Rect);
+ fn byval_rect_with_many_huge64(
+ a: Huge64, b: Huge64, c: Huge64,
+ d: Huge64, e: Huge64, f: Huge64,
+ g: Rect,
+ );
+
fn split_rect(a: i32, b: i32, s: Rect);
fn split_rect_floats(a: f32, b: f32, s: FloatRect);
@@ -95,6 +111,8 @@ extern "C" {
fn huge_struct(s: Huge) -> Huge;
+ fn huge64_struct(s: Huge64) -> Huge64;
+
fn float_point(p: FloatPoint) -> FloatPoint;
fn float_one(f: FloatOne) -> FloatOne;
@@ -107,6 +125,7 @@ fn main() {
let t = BiggerRect { s: s, a: 27834, b: 7657 };
let u = FloatRect { a: 3489, b: 3490, c: 8. };
let v = Huge { a: 5647, b: 5648, c: 5649, d: 5650, e: 5651 };
+ let w = Huge64 { a: 1234, b: 1335, c: 1436, d: 1537, e: 1638 };
let p = FloatPoint { x: 5., y: -3. };
let f1 = FloatOne { x: 7. };
let i = IntOdd { a: 1, b: 2, c: 3 };
@@ -117,12 +136,14 @@ fn main() {
byval_rect_floats(1., 2., 3., 4., 5., 6., 7., s, u);
byval_rect_with_float(1, 2, 3.0, 4, 5, 6, s);
byval_rect_with_many_huge(v, v, v, v, v, v, Rect { a: 123, b: 456, c: 789, d: 420 });
+ byval_rect_with_many_huge64(w, w, w, w, w, w, Rect { a: 1234, b: 4567, c: 7890, d: 4209 });
split_rect(1, 2, s);
split_rect_floats(1., 2., u);
split_rect_with_floats(1, 2, 3.0, 4, 5.0, 6, s);
split_and_byval_rect(1, 2, 3, s, s);
split_rect(1, 2, s);
assert_eq!(huge_struct(v), v);
+ assert_eq!(huge64_struct(w), w);
assert_eq!(split_ret_byval_struct(1, 2, s), s);
assert_eq!(sret_byval_struct(1, 2, 3, 4, s), t);
assert_eq!(sret_split_struct(1, 2, s), t);
diff --git a/tests/run-make/incr-foreign-head-span/Makefile b/tests/run-make/incr-foreign-head-span/Makefile
index 9d6102cdd..9be4b0f60 100644
--- a/tests/run-make/incr-foreign-head-span/Makefile
+++ b/tests/run-make/incr-foreign-head-span/Makefile
@@ -15,7 +15,7 @@ INCR=$(TMPDIR)/incr
all:
cp first_crate.rs second_crate.rs $(TMPDIR)
$(RUSTC) $(TMPDIR)/first_crate.rs -C incremental=$(INCR) --target $(TARGET) --crate-type lib
- $(RUSTC) $(TMPDIR)/second_crate.rs -C incremental=$(INCR) --target $(TARGET) --extern first-crate=$(TMPDIR) --crate-type lib
+ $(RUSTC) $(TMPDIR)/second_crate.rs -C incremental=$(INCR) --target $(TARGET) --extern first_crate=$(TMPDIR)/libfirst_crate.rlib --crate-type lib
rm $(TMPDIR)/first_crate.rs
$(RUSTC) $(TMPDIR)/second_crate.rs -C incremental=$(INCR) --target $(TARGET) --cfg second_run --crate-type lib
diff --git a/tests/run-make/intrinsic-unreachable/exit-ret.rs b/tests/run-make/intrinsic-unreachable/exit-ret.rs
index e7b9694d9..c8ba5b459 100644
--- a/tests/run-make/intrinsic-unreachable/exit-ret.rs
+++ b/tests/run-make/intrinsic-unreachable/exit-ret.rs
@@ -2,6 +2,7 @@
use std::arch::asm;
#[deny(unreachable_code)]
+#[inline(never)]
pub fn exit(n: usize) -> i32 {
unsafe {
// Pretend this asm is an exit() syscall.
diff --git a/tests/run-make/intrinsic-unreachable/exit-unreachable.rs b/tests/run-make/intrinsic-unreachable/exit-unreachable.rs
index ec85db733..75f893eb2 100644
--- a/tests/run-make/intrinsic-unreachable/exit-unreachable.rs
+++ b/tests/run-make/intrinsic-unreachable/exit-unreachable.rs
@@ -5,6 +5,7 @@ use std::arch::asm;
use std::intrinsics;
#[allow(unreachable_code)]
+#[inline(never)]
pub fn exit(n: usize) -> i32 {
unsafe {
// Pretend this asm is an exit() syscall.
diff --git a/tests/run-make/issue-71519/Makefile b/tests/run-make/issue-71519/Makefile
deleted file mode 100644
index 0ee83328b..000000000
--- a/tests/run-make/issue-71519/Makefile
+++ /dev/null
@@ -1,8 +0,0 @@
-include ../tools.mk
-
-# ignore-msvc
-# needs-rust-lld
-# ignore-s390x lld does not yet support s390x as target
-all:
- RUSTC_LOG=rustc_codegen_ssa::back::link=info $(RUSTC) -Z gcc-ld=lld -C link-args=-Wl,-v main.rs 2> $(TMPDIR)/output.txt
- $(CGREP) -e "^LLD [0-9]+\.[0-9]+\.[0-9]+" < $(TMPDIR)/output.txt
diff --git a/tests/run-make/issue-71519/main.rs b/tests/run-make/issue-71519/main.rs
deleted file mode 100644
index f8d09e897..000000000
--- a/tests/run-make/issue-71519/main.rs
+++ /dev/null
@@ -1,4 +0,0 @@
-// test linking using cc with rust-lld injected into search path as ld
-// see rust-lang/rust#71519 for more info
-
-fn main() {}
diff --git a/tests/run-make/issue-88756-default-output/output-default.stdout b/tests/run-make/issue-88756-default-output/output-default.stdout
index b28069823..38a3965f0 100644
--- a/tests/run-make/issue-88756-default-output/output-default.stdout
+++ b/tests/run-make/issue-88756-default-output/output-default.stdout
@@ -100,7 +100,7 @@ Options:
check if given theme is valid
--resource-suffix PATH
suffix to add to CSS and JavaScript files, e.g.,
- "light.css" will become "light-suffix.css"
+ "search-index.js" will become "search-index-suffix.js"
--edition EDITION
edition to use when compiling rust code (default:
2015)
@@ -133,9 +133,6 @@ Options:
Path string to force loading static files from in
output pages. If not set, uses combinations of '../'
to reach the documentation root.
- --disable-per-crate-search
- disables generating the crate selector on the search
- box
--persist-doctests PATH
Directory to persist doctest executables into
--show-coverage
@@ -191,6 +188,8 @@ Options:
removed, see issue #44136
<https://github.com/rust-lang/rust/issues/44136> for
more information
+ --html-no-source
+ Disable HTML source code pages generation
@path Read newline separated options from `path`
diff --git a/tests/run-make/issue-96498/Makefile b/tests/run-make/issue-96498/Makefile
deleted file mode 100644
index efdd328c6..000000000
--- a/tests/run-make/issue-96498/Makefile
+++ /dev/null
@@ -1,8 +0,0 @@
-# only-windows
-# needs-rust-lld
-
-include ../tools.mk
-
-# Ensure that LLD can link
-all:
- $(RUSTC) -C linker=rust-lld foo.rs
diff --git a/tests/run-make/jobserver-error/Makefile b/tests/run-make/jobserver-error/Makefile
index 4a1699cc7..a7601b867 100644
--- a/tests/run-make/jobserver-error/Makefile
+++ b/tests/run-make/jobserver-error/Makefile
@@ -1,9 +1,15 @@
include ../tools.mk
# only-linux
-# ignore-test: This test randomly fails, see https://github.com/rust-lang/rust/issues/110321
+# ignore-cross-compile
-# Test compiler behavior in case: `jobserver-auth` points to correct pipe which is not jobserver.
+# Test compiler behavior in case environment specifies wrong jobserver.
all:
- bash -c 'echo "fn main() {}" | MAKEFLAGS="--jobserver-auth=3,3" $(RUSTC) - 3</dev/null' 2>&1 | diff jobserver.stderr -
+ bash -c 'echo "fn main() {}" | MAKEFLAGS="--jobserver-auth=3,3" $(RUSTC)' 2>&1 | diff cannot_open_fd.stderr -
+ bash -c 'echo "fn main() {}" | MAKEFLAGS="--jobserver-auth=3,3" $(RUSTC) - 3</dev/null' 2>&1 | diff not_a_pipe.stderr -
+
+# This test randomly fails, see https://github.com/rust-lang/rust/issues/110321
+disabled:
+ bash -c 'echo "fn main() {}" | MAKEFLAGS="--jobserver-auth=3,3" $(RUSTC) - 3< <(cat /dev/null)' 2>&1 | diff poisoned_pipe.stderr -
+
diff --git a/tests/run-make/jobserver-error/cannot_open_fd.stderr b/tests/run-make/jobserver-error/cannot_open_fd.stderr
new file mode 100644
index 000000000..343de5cd5
--- /dev/null
+++ b/tests/run-make/jobserver-error/cannot_open_fd.stderr
@@ -0,0 +1,6 @@
+warning: failed to connect to jobserver from environment variable `MAKEFLAGS="--jobserver-auth=3,3"`: cannot open file descriptor 3 from the jobserver environment variable value: Bad file descriptor (os error 9)
+ |
+ = note: the build environment is likely misconfigured
+
+error: no input filename given
+
diff --git a/tests/run-make/jobserver-error/not_a_pipe.stderr b/tests/run-make/jobserver-error/not_a_pipe.stderr
new file mode 100644
index 000000000..536c04576
--- /dev/null
+++ b/tests/run-make/jobserver-error/not_a_pipe.stderr
@@ -0,0 +1,4 @@
+warning: failed to connect to jobserver from environment variable `MAKEFLAGS="--jobserver-auth=3,3"`: file descriptor 3 from the jobserver environment variable value is not a pipe
+ |
+ = note: the build environment is likely misconfigured
+
diff --git a/tests/run-make/jobserver-error/jobserver.stderr b/tests/run-make/jobserver-error/poisoned_pipe.stderr
index d18e15a26..d129db9bc 100644
--- a/tests/run-make/jobserver-error/jobserver.stderr
+++ b/tests/run-make/jobserver-error/poisoned_pipe.stderr
@@ -1,4 +1,4 @@
error: failed to acquire jobserver token: early EOF on jobserver pipe
-error: aborting due to previous error
+error: aborting due to 1 previous error
diff --git a/tests/run-make/libtest-json/output-default.json b/tests/run-make/libtest-json/output-default.json
index ad22b66ed..01710f59e 100644
--- a/tests/run-make/libtest-json/output-default.json
+++ b/tests/run-make/libtest-json/output-default.json
@@ -2,7 +2,7 @@
{ "type": "test", "event": "started", "name": "a" }
{ "type": "test", "name": "a", "event": "ok" }
{ "type": "test", "event": "started", "name": "b" }
-{ "type": "test", "name": "b", "event": "failed", "stdout": "thread 'b' panicked at 'assertion failed: false', f.rs:9:5\nnote: run with `RUST_BACKTRACE=1` environment variable to display a backtrace\n" }
+{ "type": "test", "name": "b", "event": "failed", "stdout": "thread 'b' panicked at f.rs:9:5:\nassertion failed: false\nnote: run with `RUST_BACKTRACE=1` environment variable to display a backtrace\n" }
{ "type": "test", "event": "started", "name": "c" }
{ "type": "test", "name": "c", "event": "ok" }
{ "type": "test", "event": "started", "name": "d" }
diff --git a/tests/run-make/libtest-json/output-stdout-success.json b/tests/run-make/libtest-json/output-stdout-success.json
index ec98172eb..878eb6c7c 100644
--- a/tests/run-make/libtest-json/output-stdout-success.json
+++ b/tests/run-make/libtest-json/output-stdout-success.json
@@ -2,9 +2,9 @@
{ "type": "test", "event": "started", "name": "a" }
{ "type": "test", "name": "a", "event": "ok", "stdout": "print from successful test\n" }
{ "type": "test", "event": "started", "name": "b" }
-{ "type": "test", "name": "b", "event": "failed", "stdout": "thread 'b' panicked at 'assertion failed: false', f.rs:9:5\nnote: run with `RUST_BACKTRACE=1` environment variable to display a backtrace\n" }
+{ "type": "test", "name": "b", "event": "failed", "stdout": "thread 'b' panicked at f.rs:9:5:\nassertion failed: false\nnote: run with `RUST_BACKTRACE=1` environment variable to display a backtrace\n" }
{ "type": "test", "event": "started", "name": "c" }
-{ "type": "test", "name": "c", "event": "ok", "stdout": "thread 'c' panicked at 'assertion failed: false', f.rs:15:5\n" }
+{ "type": "test", "name": "c", "event": "ok", "stdout": "thread 'c' panicked at f.rs:15:5:\nassertion failed: false\n" }
{ "type": "test", "event": "started", "name": "d" }
{ "type": "test", "name": "d", "event": "ignored", "message": "msg" }
{ "type": "suite", "event": "failed", "passed": 2, "failed": 1, "ignored": 1, "measured": 0, "filtered_out": 0, "exec_time": $TIME }
diff --git a/tests/run-make/libtest-junit/output-default.xml b/tests/run-make/libtest-junit/output-default.xml
index d59e07b8a..58a9a2874 100644
--- a/tests/run-make/libtest-junit/output-default.xml
+++ b/tests/run-make/libtest-junit/output-default.xml
@@ -1 +1 @@
-<?xml version="1.0" encoding="UTF-8"?><testsuites><testsuite name="test" package="test" id="0" errors="0" failures="1" tests="4" skipped="1" ><testcase classname="unknown" name="a" time="$TIME"/><testcase classname="unknown" name="b" time="$TIME"><failure type="assert"/><system-out><![CDATA[print from failing test]]>&#xA;<![CDATA[thread 'b' panicked at 'assertion failed: false', f.rs:10:5]]>&#xA;<![CDATA[note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace]]>&#xA;<![CDATA[]]></system-out></testcase><testcase classname="unknown" name="c" time="$TIME"/><system-out/><system-err/></testsuite></testsuites>
+<?xml version="1.0" encoding="UTF-8"?><testsuites><testsuite name="test" package="test" id="0" errors="0" failures="1" tests="4" skipped="1" ><testcase classname="unknown" name="a" time="$TIME"/><testcase classname="unknown" name="b" time="$TIME"><failure type="assert"/><system-out><![CDATA[print from failing test]]>&#xA;<![CDATA[thread 'b' panicked at f.rs:10:5:]]>&#xA;<![CDATA[assertion failed: false]]>&#xA;<![CDATA[note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace]]>&#xA;<![CDATA[]]></system-out></testcase><testcase classname="unknown" name="c" time="$TIME"/><system-out/><system-err/></testsuite></testsuites>
diff --git a/tests/run-make/libtest-junit/output-stdout-success.xml b/tests/run-make/libtest-junit/output-stdout-success.xml
index 0c300611e..723816a4a 100644
--- a/tests/run-make/libtest-junit/output-stdout-success.xml
+++ b/tests/run-make/libtest-junit/output-stdout-success.xml
@@ -1 +1 @@
-<?xml version="1.0" encoding="UTF-8"?><testsuites><testsuite name="test" package="test" id="0" errors="0" failures="1" tests="4" skipped="1" ><testcase classname="unknown" name="a" time="$TIME"><system-out><![CDATA[print from successful test]]>&#xA;<![CDATA[]]></system-out></testcase><testcase classname="unknown" name="b" time="$TIME"><failure type="assert"/><system-out><![CDATA[print from failing test]]>&#xA;<![CDATA[thread 'b' panicked at 'assertion failed: false', f.rs:10:5]]>&#xA;<![CDATA[note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace]]>&#xA;<![CDATA[]]></system-out></testcase><testcase classname="unknown" name="c" time="$TIME"><system-out><![CDATA[thread 'c' panicked at 'assertion failed: false', f.rs:16:5]]>&#xA;<![CDATA[]]></system-out></testcase><system-out/><system-err/></testsuite></testsuites>
+<?xml version="1.0" encoding="UTF-8"?><testsuites><testsuite name="test" package="test" id="0" errors="0" failures="1" tests="4" skipped="1" ><testcase classname="unknown" name="a" time="$TIME"><system-out><![CDATA[print from successful test]]>&#xA;<![CDATA[]]></system-out></testcase><testcase classname="unknown" name="b" time="$TIME"><failure type="assert"/><system-out><![CDATA[print from failing test]]>&#xA;<![CDATA[thread 'b' panicked at f.rs:10:5:]]>&#xA;<![CDATA[assertion failed: false]]>&#xA;<![CDATA[note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace]]>&#xA;<![CDATA[]]></system-out></testcase><testcase classname="unknown" name="c" time="$TIME"><system-out><![CDATA[thread 'c' panicked at f.rs:16:5:]]>&#xA;<![CDATA[assertion failed: false]]>&#xA;<![CDATA[]]></system-out></testcase><system-out/><system-err/></testsuite></testsuites>
diff --git a/tests/run-make/libtest-junit/validate_junit.py b/tests/run-make/libtest-junit/validate_junit.py
index 47a8e70cc..0d9b34a3c 100755
--- a/tests/run-make/libtest-junit/validate_junit.py
+++ b/tests/run-make/libtest-junit/validate_junit.py
@@ -7,6 +7,6 @@ import xml.etree.ElementTree as ET
for line in sys.stdin:
try:
ET.fromstring(line)
- except ET.ParseError as pe:
+ except ET.ParseError:
print("Invalid xml: %r" % line)
raise
diff --git a/tests/run-make/llvm-ident/Makefile b/tests/run-make/llvm-ident/Makefile
new file mode 100644
index 000000000..e583e6018
--- /dev/null
+++ b/tests/run-make/llvm-ident/Makefile
@@ -0,0 +1,19 @@
+include ../tools.mk
+
+# only-linux
+
+all:
+ # `-Ccodegen-units=16 -Copt-level=2` is used here to trigger thin LTO
+ # across codegen units to test deduplication of the named metadata
+ # (see `LLVMRustPrepareThinLTOImport` for details).
+ echo 'fn main(){}' | $(RUSTC) - --emit=link,obj -Csave-temps -Ccodegen-units=16 -Copt-level=2 --target=$(TARGET)
+
+ # `llvm-dis` is used here since `--emit=llvm-ir` does not emit LLVM IR
+ # for temporary outputs.
+ "$(LLVM_BIN_DIR)"/llvm-dis $(TMPDIR)/*.bc
+
+ # Check LLVM IR files (including temporary outputs) have `!llvm.ident`
+ # named metadata, reusing the related codegen test.
+ set -e; for f in $(TMPDIR)/*.ll; do \
+ $(LLVM_FILECHECK) --input-file $$f ../../codegen/llvm-ident.rs; \
+ done
diff --git a/tests/run-make/ls-metadata/Makefile b/tests/run-make/ls-metadata/Makefile
index 123dd64e1..f03569bae 100644
--- a/tests/run-make/ls-metadata/Makefile
+++ b/tests/run-make/ls-metadata/Makefile
@@ -3,6 +3,6 @@ include ../tools.mk
all:
$(RUSTC) foo.rs
- $(RUSTC) -Z ls $(TMPDIR)/foo
+ $(RUSTC) -Z ls=root $(TMPDIR)/foo
touch $(TMPDIR)/bar
- $(RUSTC) -Z ls $(TMPDIR)/bar
+ $(RUSTC) -Z ls=root $(TMPDIR)/bar
diff --git a/tests/run-make/lto-linkage-used-attr/Makefile b/tests/run-make/lto-linkage-used-attr/Makefile
new file mode 100644
index 000000000..e78b83890
--- /dev/null
+++ b/tests/run-make/lto-linkage-used-attr/Makefile
@@ -0,0 +1,9 @@
+include ../tools.mk
+
+# Verify that the impl_* symbols are preserved. #108030
+# only-x86_64-unknown-linux-gnu
+# min-llvm-version: 17
+
+all:
+ $(RUSTC) -Cdebuginfo=0 -Copt-level=3 lib.rs
+ $(RUSTC) -Clto=fat -Cdebuginfo=0 -Copt-level=3 main.rs
diff --git a/tests/run-make/lto-linkage-used-attr/lib.rs b/tests/run-make/lto-linkage-used-attr/lib.rs
new file mode 100644
index 000000000..0a92ea9cd
--- /dev/null
+++ b/tests/run-make/lto-linkage-used-attr/lib.rs
@@ -0,0 +1,50 @@
+#![crate_type = "rlib"]
+#![crate_type = "cdylib"]
+
+#[macro_export]
+macro_rules! asm_func {
+ ($name:expr, $body:expr $(, $($args:tt)*)?) => {
+ core::arch::global_asm!(
+ concat!(
+ ".p2align 4\n",
+ ".hidden ", $name, "\n",
+ ".global ", $name, "\n",
+ ".type ", $name, ",@function\n",
+ $name, ":\n",
+ $body,
+ ".size ", $name, ",.-", $name,
+ )
+ $(, $($args)*)?
+ );
+ };
+}
+
+macro_rules! libcall_trampoline {
+ ($libcall:ident ; $libcall_impl:ident) => {
+ asm_func!(
+ stringify!($libcall),
+ concat!(
+ "
+ .cfi_startproc simple
+ .cfi_def_cfa_offset 0
+ jmp {}
+ .cfi_endproc
+ ",
+ ),
+ sym $libcall_impl
+ );
+ };
+}
+
+pub mod trampolines {
+ extern "C" {
+ pub fn table_fill_funcref();
+ pub fn table_fill_externref();
+ }
+
+ unsafe extern "C" fn impl_table_fill_funcref() {}
+ unsafe extern "C" fn impl_table_fill_externref() {}
+
+ libcall_trampoline!(table_fill_funcref ; impl_table_fill_funcref);
+ libcall_trampoline!(table_fill_externref ; impl_table_fill_externref);
+}
diff --git a/tests/run-make/lto-linkage-used-attr/main.rs b/tests/run-make/lto-linkage-used-attr/main.rs
new file mode 100644
index 000000000..256b02e5b
--- /dev/null
+++ b/tests/run-make/lto-linkage-used-attr/main.rs
@@ -0,0 +1,10 @@
+extern crate lib;
+
+use lib::trampolines::*;
+
+fn main() {
+ unsafe {
+ table_fill_externref();
+ table_fill_funcref();
+ }
+}
diff --git a/tests/run-make/macos-deployment-target/Makefile b/tests/run-make/macos-deployment-target/Makefile
index d0cf836bc..757ca6995 100644
--- a/tests/run-make/macos-deployment-target/Makefile
+++ b/tests/run-make/macos-deployment-target/Makefile
@@ -9,12 +9,12 @@ include ../tools.mk
ifeq ($(strip $(shell uname -m)),arm64)
GREP_PATTERN = "minos 11.0"
else
- GREP_PATTERN = "version 10.9"
+ GREP_PATTERN = "version 10.13"
endif
OUT_FILE=$(TMPDIR)/with_deployment_target.dylib
all:
- env MACOSX_DEPLOYMENT_TARGET=10.9 $(RUSTC) with_deployment_target.rs -o $(OUT_FILE)
+ env MACOSX_DEPLOYMENT_TARGET=10.13 $(RUSTC) with_deployment_target.rs -o $(OUT_FILE)
# XXX: The check is for either the x86_64 minimum OR the aarch64 minimum (M1 starts at macOS 11).
# They also use different load commands, so we let that change with each too. The aarch64 check
# isn't as robust as the x86 one, but testing both seems unneeded.
diff --git a/tests/run-make/metadata-dep-info/Makefile b/tests/run-make/metadata-dep-info/Makefile
new file mode 100644
index 000000000..d48cbe0f2
--- /dev/null
+++ b/tests/run-make/metadata-dep-info/Makefile
@@ -0,0 +1,7 @@
+include ../tools.mk
+
+all:
+ $(RUSTC) --emit=metadata,dep-info --crate-type lib dash-separated.rs -C extra-filename=_something-extra
+ # Strip TMPDIR since it is a machine specific absolute path
+ sed "s%.*[/\\]%%" "$(TMPDIR)"/dash-separated_something-extra.d > "$(TMPDIR)"/dash-separated_something-extra.normalized.d
+ $(RUSTC_TEST_OP) "$(TMPDIR)"/dash-separated_something-extra.normalized.d dash-separated_something-extra.normalized.d
diff --git a/tests/run-make/metadata-dep-info/dash-separated.rs b/tests/run-make/metadata-dep-info/dash-separated.rs
new file mode 100644
index 000000000..4202afd3d
--- /dev/null
+++ b/tests/run-make/metadata-dep-info/dash-separated.rs
@@ -0,0 +1,4 @@
+//! It is important that this file has at least one `-` in the file name since
+//! we want to test that it becomes a `_` when appropriate.
+
+pub struct Foo;
diff --git a/tests/run-make/metadata-dep-info/dash-separated_something-extra.normalized.d b/tests/run-make/metadata-dep-info/dash-separated_something-extra.normalized.d
new file mode 100644
index 000000000..497d76b4e
--- /dev/null
+++ b/tests/run-make/metadata-dep-info/dash-separated_something-extra.normalized.d
@@ -0,0 +1,5 @@
+libdash_separated_something-extra.rmeta: dash-separated.rs
+
+dash-separated_something-extra.d: dash-separated.rs
+
+dash-separated.rs:
diff --git a/tests/run-make/mixing-libs/Makefile b/tests/run-make/mixing-libs/Makefile
index e8262b284..459db0dfd 100644
--- a/tests/run-make/mixing-libs/Makefile
+++ b/tests/run-make/mixing-libs/Makefile
@@ -2,9 +2,7 @@
include ../tools.mk
all:
- $(RUSTC) rlib.rs
- $(RUSTC) dylib.rs
- $(RUSTC) rlib.rs --crate-type=dylib
- $(RUSTC) dylib.rs
- $(call REMOVE_DYLIBS,rlib)
+ $(RUSTC) rlib.rs --crate-type=rlib --crate-type=dylib
+ $(RUSTC) dylib.rs # no -Cprefer-dynamic so statically linking librlib.rlib
+ $(call REMOVE_DYLIBS,rlib) # remove librlib.so to test that prog.rs doesn't get confused about the removed dylib version of librlib
$(RUSTC) prog.rs && exit 1 || exit 0
diff --git a/tests/run-make/no-builtins-attribute/Makefile b/tests/run-make/no-builtins-attribute/Makefile
new file mode 100644
index 000000000..0ce95faca
--- /dev/null
+++ b/tests/run-make/no-builtins-attribute/Makefile
@@ -0,0 +1,9 @@
+include ../tools.mk
+
+# We want to check if `no-builtins` is also added to the function declarations in the used crate.
+
+all:
+ $(RUSTC) no_builtins.rs --emit=link
+ $(RUSTC) main.rs --emit=llvm-ir
+
+ cat "$(TMPDIR)"/main.ll | "$(LLVM_FILECHECK)" filecheck.main.txt
diff --git a/tests/run-make/no-builtins-attribute/filecheck.main.txt b/tests/run-make/no-builtins-attribute/filecheck.main.txt
new file mode 100644
index 000000000..ecd650bdc
--- /dev/null
+++ b/tests/run-make/no-builtins-attribute/filecheck.main.txt
@@ -0,0 +1,5 @@
+CHECK: declare void @foo()
+CHECK-SAME: #[[ATTR_3:[0-9]+]]
+
+CHECK: attributes #[[ATTR_3]]
+CHECK-SAME: no-builtins
diff --git a/tests/run-make/no-builtins-attribute/main.rs b/tests/run-make/no-builtins-attribute/main.rs
new file mode 100644
index 000000000..77754b37e
--- /dev/null
+++ b/tests/run-make/no-builtins-attribute/main.rs
@@ -0,0 +1,10 @@
+extern crate no_builtins;
+
+#[no_mangle]
+fn call_foo() {
+ no_builtins::foo();
+}
+
+fn main() {
+ call_foo();
+}
diff --git a/tests/run-make/no-builtins-attribute/no_builtins.rs b/tests/run-make/no-builtins-attribute/no_builtins.rs
new file mode 100644
index 000000000..8ca862d2f
--- /dev/null
+++ b/tests/run-make/no-builtins-attribute/no_builtins.rs
@@ -0,0 +1,5 @@
+#![crate_type = "lib"]
+#![no_builtins]
+
+#[no_mangle]
+pub fn foo() {}
diff --git a/tests/run-make/no-cdylib-as-rdylib/Makefile b/tests/run-make/no-cdylib-as-rdylib/Makefile
new file mode 100644
index 000000000..4d2be0aea
--- /dev/null
+++ b/tests/run-make/no-cdylib-as-rdylib/Makefile
@@ -0,0 +1,16 @@
+# ignore-cross-compile
+include ../tools.mk
+
+# Test that rustc will not attempt to link against a cdylib as if
+# it is a rust dylib when an rlib for the same crate is available.
+# Previously rustc didn't actually check if any further formats of
+# a crate which has been loaded are of the same version and if
+# they are actually valid. This caused a cdylib to be interpreted
+# as rust dylib as soon as the corresponding rlib was loaded. As
+# cdylibs don't export any rust symbols, linking would fail if
+# rustc decides to link against the cdylib rather than the rlib.
+
+all:
+ $(RUSTC) bar.rs --crate-type=rlib --crate-type=cdylib
+ $(RUSTC) foo.rs -C prefer-dynamic
+ $(call RUN,foo)
diff --git a/tests/run-make/no-cdylib-as-rdylib/bar.rs b/tests/run-make/no-cdylib-as-rdylib/bar.rs
new file mode 100644
index 000000000..c5c0bc606
--- /dev/null
+++ b/tests/run-make/no-cdylib-as-rdylib/bar.rs
@@ -0,0 +1 @@
+pub fn bar() {}
diff --git a/tests/run-make/no-cdylib-as-rdylib/foo.rs b/tests/run-make/no-cdylib-as-rdylib/foo.rs
new file mode 100644
index 000000000..8d68535e3
--- /dev/null
+++ b/tests/run-make/no-cdylib-as-rdylib/foo.rs
@@ -0,0 +1,5 @@
+extern crate bar;
+
+fn main() {
+ bar::bar();
+}
diff --git a/tests/run-make/optimization-remarks-dir-pgo/Makefile b/tests/run-make/optimization-remarks-dir-pgo/Makefile
new file mode 100644
index 000000000..3bc3d7d14
--- /dev/null
+++ b/tests/run-make/optimization-remarks-dir-pgo/Makefile
@@ -0,0 +1,21 @@
+# needs-profiler-support
+# ignore-windows-gnu
+# ignore-cross-compile
+
+# FIXME(mati865): MinGW GCC miscompiles compiler-rt profiling library but with Clang it works
+# properly. Since we only have GCC on the CI ignore the test for now.
+
+include ../tools.mk
+
+PROFILE_DIR=$(TMPDIR)/profiles
+
+check_hotness:
+ $(RUSTC) -Cprofile-generate="$(TMPDIR)"/profdata -O foo.rs -o$(TMPDIR)/foo
+ $(TMPDIR)/foo
+ "$(LLVM_BIN_DIR)"/llvm-profdata merge \
+ -o "$(TMPDIR)"/merged.profdata \
+ "$(TMPDIR)"/profdata/*.profraw
+ $(RUSTC) -Cprofile-use=$(TMPDIR)/merged.profdata -O foo.rs -Cremark=all -Zremark-dir=$(PROFILE_DIR)
+
+ # Check that PGO hotness is included in the remark files
+ cat $(PROFILE_DIR)/*.opt.yaml | $(CGREP) -e "Hotness"
diff --git a/tests/run-make/optimization-remarks-dir-pgo/foo.rs b/tests/run-make/optimization-remarks-dir-pgo/foo.rs
new file mode 100644
index 000000000..f7ca18263
--- /dev/null
+++ b/tests/run-make/optimization-remarks-dir-pgo/foo.rs
@@ -0,0 +1,6 @@
+#[inline(never)]
+pub fn bar() {}
+
+fn main() {
+ bar();
+}
diff --git a/tests/run-make/optimization-remarks-dir/Makefile b/tests/run-make/optimization-remarks-dir/Makefile
new file mode 100644
index 000000000..a8342c8ad
--- /dev/null
+++ b/tests/run-make/optimization-remarks-dir/Makefile
@@ -0,0 +1,12 @@
+include ../tools.mk
+
+PROFILE_DIR=$(TMPDIR)/profiles
+
+all: check_inline check_filter
+
+check_inline:
+ $(RUSTC) -O foo.rs --crate-type=lib -Cremark=all -Zremark-dir=$(PROFILE_DIR)
+ cat $(PROFILE_DIR)/*.opt.yaml | $(CGREP) -e "inline"
+check_filter:
+ $(RUSTC) -O foo.rs --crate-type=lib -Cremark=foo -Zremark-dir=$(PROFILE_DIR)
+ cat $(PROFILE_DIR)/*.opt.yaml | $(CGREP) -e -v "inline"
diff --git a/tests/run-make/optimization-remarks-dir/foo.rs b/tests/run-make/optimization-remarks-dir/foo.rs
new file mode 100644
index 000000000..6ac3af0dc
--- /dev/null
+++ b/tests/run-make/optimization-remarks-dir/foo.rs
@@ -0,0 +1,6 @@
+#[inline(never)]
+pub fn bar() {}
+
+pub fn foo() {
+ bar();
+}
diff --git a/tests/run-make/output-filename-overwrites-input/Makefile b/tests/run-make/output-filename-overwrites-input/Makefile
index 605b86b25..fe5d23138 100644
--- a/tests/run-make/output-filename-overwrites-input/Makefile
+++ b/tests/run-make/output-filename-overwrites-input/Makefile
@@ -8,7 +8,7 @@ all:
cp bar.rs $(TMPDIR)/bar.rlib
$(RUSTC) $(TMPDIR)/bar.rlib -o $(TMPDIR)/bar.rlib 2>&1 \
| $(CGREP) -e "the input file \".*bar.rlib\" would be overwritten by the generated executable"
- $(RUSTC) foo.rs 2>&1 && $(RUSTC) -Z ls $(TMPDIR)/foo 2>&1
+ $(RUSTC) foo.rs 2>&1 && $(RUSTC) -Z ls=root $(TMPDIR)/foo 2>&1
cp foo.rs $(TMPDIR)/foo.rs
$(RUSTC) $(TMPDIR)/foo.rs -o $(TMPDIR)/foo.rs 2>&1 \
| $(CGREP) -e "the input file \".*foo.rs\" would be overwritten by the generated executable"
diff --git a/tests/run-make/overwrite-input/Makefile b/tests/run-make/overwrite-input/Makefile
index c62b5aab1..721bf62b2 100644
--- a/tests/run-make/overwrite-input/Makefile
+++ b/tests/run-make/overwrite-input/Makefile
@@ -3,11 +3,5 @@ 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"
-
-ifdef RUSTC_BLESS_TEST
- cp "$(TMPDIR)"/file.stderr file.stderr
- cp "$(TMPDIR)"/folder.stderr folder.stderr
-else
- $(DIFF) file.stderr "$(TMPDIR)"/file.stderr
- $(DIFF) folder.stderr "$(TMPDIR)"/folder.stderr
-endif
+ $(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 9936962b4..c13a270b0 100644
--- a/tests/run-make/overwrite-input/file.stderr
+++ b/tests/run-make/overwrite-input/file.stderr
@@ -2,5 +2,5 @@ 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 previous error; 1 warning emitted
+error: aborting due to 1 previous error; 1 warning emitted
diff --git a/tests/run-make/overwrite-input/folder.stderr b/tests/run-make/overwrite-input/folder.stderr
index 81b1e7367..6e51cb812 100644
--- a/tests/run-make/overwrite-input/folder.stderr
+++ b/tests/run-make/overwrite-input/folder.stderr
@@ -2,5 +2,5 @@ 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 previous error; 1 warning emitted
+error: aborting due to 1 previous error; 1 warning emitted
diff --git a/tests/run-make/overwrite-input/main.stderr b/tests/run-make/overwrite-input/main.stderr
index 9936962b4..c13a270b0 100644
--- a/tests/run-make/overwrite-input/main.stderr
+++ b/tests/run-make/overwrite-input/main.stderr
@@ -2,5 +2,5 @@ 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 previous error; 1 warning emitted
+error: aborting due to 1 previous error; 1 warning emitted
diff --git a/tests/run-make/panic-abort-eh_frame/Makefile b/tests/run-make/panic-abort-eh_frame/Makefile
new file mode 100644
index 000000000..7020455b7
--- /dev/null
+++ b/tests/run-make/panic-abort-eh_frame/Makefile
@@ -0,0 +1,10 @@
+# only-linux
+#
+# This test ensures that `panic=abort` code (without `C-unwind`, that is) should not have any
+# unwinding related `.eh_frame` sections emitted.
+
+include ../tools.mk
+
+all:
+ $(RUSTC) foo.rs --crate-type=lib --emit=obj=$(TMPDIR)/foo.o -Cpanic=abort --edition 2021 -Z validate-mir
+ objdump --dwarf=frames $(TMPDIR)/foo.o | $(CGREP) -v 'DW_CFA'
diff --git a/tests/run-make/panic-abort-eh_frame/foo.rs b/tests/run-make/panic-abort-eh_frame/foo.rs
new file mode 100644
index 000000000..e2274d469
--- /dev/null
+++ b/tests/run-make/panic-abort-eh_frame/foo.rs
@@ -0,0 +1,34 @@
+#![no_std]
+
+use core::future::Future;
+
+pub struct NeedsDrop;
+
+impl Drop for NeedsDrop {
+ fn drop(&mut self) {}
+}
+
+#[panic_handler]
+fn handler(_: &core::panic::PanicInfo<'_>) -> ! {
+ loop {}
+}
+
+pub unsafe fn oops(x: *const u32) -> u32 {
+ *x
+}
+
+pub async fn foo(_: NeedsDrop) {
+ async fn bar() {}
+ bar().await;
+}
+
+pub fn poll_foo(x: &mut core::task::Context<'_>) {
+ let _g = NeedsDrop;
+ let mut p = core::pin::pin!(foo(NeedsDrop));
+ let _ = p.as_mut().poll(x);
+ let _ = p.as_mut().poll(x);
+}
+
+pub fn drop_foo() {
+ drop(foo(NeedsDrop));
+}
diff --git a/tests/run-make/pass-linker-flags-flavor/Makefile b/tests/run-make/pass-linker-flags-flavor/Makefile
new file mode 100644
index 000000000..1bb05d0f9
--- /dev/null
+++ b/tests/run-make/pass-linker-flags-flavor/Makefile
@@ -0,0 +1,11 @@
+# only-linux
+
+include ../tools.mk
+
+all:
+ $(RUSTC) empty.rs -Z unstable-options -C linker-flavor=gnu-cc -l static=l1 -l link-arg=a1 -l static=l2 -l link-arg=a2 -l dylib=d1 -l link-arg=a3 --print link-args | $(CGREP) -e 'l1.*-Wl,a1.*l2.*-Wl,a2.*d1.*-Wl,a3'
+ $(RUSTC) empty.rs -Z unstable-options -C linker-flavor=gnu-cc -l static=l1 -l link-arg:+verbatim=a1 -l static=l2 -l link-arg=a2 -l dylib=d1 -l link-arg=a3 --print link-args | $(CGREP) -e 'l1.*"a1".*l2.*-Wl,a2.*d1.*-Wl,a3'
+ $(RUSTC) empty.rs -Z unstable-options -C linker-flavor=ld -l static=l1 -l link-arg=a1 -l static=l2 -l link-arg=a2 -l dylib=d1 -l link-arg=a3 --print link-args | $(CGREP) -e 'l1.*"a1".*l2.*"a2".*d1.*"a3"'
+ $(RUSTC) attribute.rs -Z unstable-options -C linker-flavor=gnu-cc --print link-args | $(CGREP) -e 'l1.*-Wl,a1.*l2.*-Wl,a2.*d1.*-Wl,a3'
+ $(RUSTC) --cfg 'feature="verbatim"' attribute.rs -Z unstable-options -C linker-flavor=gnu-cc --print link-args | $(CGREP) -e 'l1.*"a1".*l2.*-Wl,a2.*d1.*-Wl,a3'
+ $(RUSTC) attribute.rs -C linker-flavor=ld --print link-args | $(CGREP) -e 'l1.*"a1".*l2.*"a2".*d1.*"a3"'
diff --git a/tests/run-make/pass-linker-flags-flavor/attribute.rs b/tests/run-make/pass-linker-flags-flavor/attribute.rs
new file mode 100644
index 000000000..d09916530
--- /dev/null
+++ b/tests/run-make/pass-linker-flags-flavor/attribute.rs
@@ -0,0 +1,12 @@
+#![feature(link_arg_attribute)]
+
+#[link(kind = "static", name = "l1")]
+#[cfg_attr(feature = "verbatim", link(kind = "link-arg", name = "a1", modifiers = "+verbatim"))]
+#[cfg_attr(not(feature = "verbatim"), link(kind = "link-arg", name = "a1"))]
+#[link(kind = "static", name = "l2")]
+#[link(kind = "link-arg", name = "a2")]
+#[link(kind = "dylib", name = "d1")]
+#[link(kind = "link-arg", name = "a3")]
+extern "C" {}
+
+fn main() {}
diff --git a/tests/run-make/pass-linker-flags/rs.rs b/tests/run-make/pass-linker-flags-flavor/empty.rs
index f328e4d9d..f328e4d9d 100644
--- a/tests/run-make/pass-linker-flags/rs.rs
+++ b/tests/run-make/pass-linker-flags-flavor/empty.rs
diff --git a/tests/run-make/pass-linker-flags-from-dep/Makefile b/tests/run-make/pass-linker-flags-from-dep/Makefile
index b57389bb7..48b3b26ce 100644
--- a/tests/run-make/pass-linker-flags-from-dep/Makefile
+++ b/tests/run-make/pass-linker-flags-from-dep/Makefile
@@ -4,7 +4,9 @@ all:
# Build deps
$(RUSTC) native_dep_1.rs --crate-type=staticlib
$(RUSTC) native_dep_2.rs --crate-type=staticlib
- $(RUSTC) rust_dep.rs -l static:-bundle=native_dep_1 -l link-arg=some_flag -l static:-bundle=native_dep_2 --crate-type=lib -Z unstable-options
+ $(RUSTC) rust_dep_flag.rs -l static:-bundle=native_dep_1 -l link-arg=some_flag -l static:-bundle=native_dep_2 --crate-type=lib -Z unstable-options
+ $(RUSTC) rust_dep_attr.rs --crate-type=lib
# Check sequence of linker args
- $(RUSTC) main.rs --extern lib=$(TMPDIR)/librust_dep.rlib --crate-type=bin --print link-args | $(CGREP) -e 'native_dep_1.*some_flag.*native_dep_2'
+ $(RUSTC) main.rs --extern lib=$(TMPDIR)/librust_dep_flag.rlib --crate-type=bin --print link-args | $(CGREP) -e 'native_dep_1.*some_flag.*native_dep_2'
+ $(RUSTC) main.rs --extern lib=$(TMPDIR)/librust_dep_attr.rlib --crate-type=bin --print link-args | $(CGREP) -e 'native_dep_1.*some_flag.*native_dep_2'
diff --git a/tests/run-make/pass-linker-flags-from-dep/rust_dep_attr.rs b/tests/run-make/pass-linker-flags-from-dep/rust_dep_attr.rs
new file mode 100644
index 000000000..ac5888ce6
--- /dev/null
+++ b/tests/run-make/pass-linker-flags-from-dep/rust_dep_attr.rs
@@ -0,0 +1,14 @@
+#![feature(link_arg_attribute)]
+
+#[link(kind = "static", name = "native_dep_1", modifiers = "-bundle")]
+#[link(kind = "link-arg", name = "some_flag")]
+#[link(kind = "static", name = "native_dep_2", modifiers = "-bundle")]
+extern "C" {
+ pub fn foo();
+}
+
+pub fn f() {
+ unsafe {
+ foo();
+ }
+}
diff --git a/tests/run-make/pass-linker-flags-from-dep/rust_dep.rs b/tests/run-make/pass-linker-flags-from-dep/rust_dep_flag.rs
index 7f5df1139..7f5df1139 100644
--- a/tests/run-make/pass-linker-flags-from-dep/rust_dep.rs
+++ b/tests/run-make/pass-linker-flags-from-dep/rust_dep_flag.rs
diff --git a/tests/run-make/pass-linker-flags/Makefile b/tests/run-make/pass-linker-flags/Makefile
index 6ddbcbb1b..226943e93 100644
--- a/tests/run-make/pass-linker-flags/Makefile
+++ b/tests/run-make/pass-linker-flags/Makefile
@@ -1,4 +1,5 @@
include ../tools.mk
all:
- $(RUSTC) rs.rs -Z unstable-options -l static=l1 -l link-arg=a1 -l static=l2 -l link-arg=a2 -l dylib=d1 -l link-arg=a3 --print link-args | $(CGREP) -e 'l1.*a1.*l2.*a2.*d1.*a3'
+ $(RUSTC) empty.rs -Z unstable-options -l static=l1 -l link-arg=a1 -l static=l2 -l link-arg=a2 -l dylib=d1 -l link-arg=a3 --print link-args | $(CGREP) -e 'l1.*a1.*l2.*a2.*d1.*a3'
+ $(RUSTC) attribute.rs --print link-args | $(CGREP) -e 'l1.*a1.*l2.*a2.*d1.*a3'
diff --git a/tests/run-make/pass-linker-flags/attribute.rs b/tests/run-make/pass-linker-flags/attribute.rs
new file mode 100644
index 000000000..6f784c01f
--- /dev/null
+++ b/tests/run-make/pass-linker-flags/attribute.rs
@@ -0,0 +1,11 @@
+#![feature(link_arg_attribute)]
+
+#[link(kind = "static", name = "l1")]
+#[link(kind = "link-arg", name = "a1")]
+#[link(kind = "static", name = "l2")]
+#[link(kind = "link-arg", name = "a2")]
+#[link(kind = "dylib", name = "d1")]
+#[link(kind = "link-arg", name = "a3")]
+extern "C" {}
+
+fn main() {}
diff --git a/tests/run-make/pass-linker-flags/empty.rs b/tests/run-make/pass-linker-flags/empty.rs
new file mode 100644
index 000000000..f328e4d9d
--- /dev/null
+++ b/tests/run-make/pass-linker-flags/empty.rs
@@ -0,0 +1 @@
+fn main() {}
diff --git a/tests/run-make/pdb-buildinfo-cl-cmd/Makefile b/tests/run-make/pdb-buildinfo-cl-cmd/Makefile
new file mode 100644
index 000000000..a7be301a5
--- /dev/null
+++ b/tests/run-make/pdb-buildinfo-cl-cmd/Makefile
@@ -0,0 +1,16 @@
+include ../tools.mk
+
+# only-windows-msvc
+
+# tests if the pdb contains the following information in the LF_BUILDINFO:
+# 1. the commandline args to compile it (cmd)
+# 2. full path to the compiler (cl)
+
+# we just do a stringsearch on the pdb, as these need to show up at least once, as the LF_BUILDINFO is created for each cgu
+# actual parsing would be better, but this is a simple and good enough solution for now
+
+all:
+ $(RUSTC_ORIGINAL) main.rs -g --crate-name my_crate_name --crate-type bin -C metadata=dc9ef878b0a48666 --out-dir $(TMPDIR)
+ cat '$(TMPDIR)/my_crate_name.pdb' | grep -F '$(RUSTC_ORIGINAL)'
+# using a file containing the string so I don't have problems with escaping quotes and spaces
+ cat '$(TMPDIR)/my_crate_name.pdb' | grep -f 'stringlist.txt'
diff --git a/tests/run-make/pdb-buildinfo-cl-cmd/main.rs b/tests/run-make/pdb-buildinfo-cl-cmd/main.rs
new file mode 100644
index 000000000..f79c691f0
--- /dev/null
+++ b/tests/run-make/pdb-buildinfo-cl-cmd/main.rs
@@ -0,0 +1,2 @@
+fn main() {
+}
diff --git a/tests/run-make/pdb-buildinfo-cl-cmd/stringlist.txt b/tests/run-make/pdb-buildinfo-cl-cmd/stringlist.txt
new file mode 100644
index 000000000..634e9f19e
--- /dev/null
+++ b/tests/run-make/pdb-buildinfo-cl-cmd/stringlist.txt
@@ -0,0 +1 @@
+"main.rs" "-g" "--crate-name" "my_crate_name" "--crate-type" "bin" "-C" "metadata=dc9ef878b0a48666" "--out-dir" \ No newline at end of file
diff --git a/tests/run-make/pgo-branch-weights/Makefile b/tests/run-make/pgo-branch-weights/Makefile
index c60206a1f..4c9f8b249 100644
--- a/tests/run-make/pgo-branch-weights/Makefile
+++ b/tests/run-make/pgo-branch-weights/Makefile
@@ -1,5 +1,6 @@
# needs-profiler-support
# ignore-windows-gnu
+# ignore-cross-compile
# FIXME(mati865): MinGW GCC miscompiles compiler-rt profiling library but with Clang it works
# properly. Since we only have GCC on the CI ignore the test for now.
diff --git a/tests/run-make/pgo-gen-lto/Makefile b/tests/run-make/pgo-gen-lto/Makefile
index 3f2f6a838..8b647846a 100644
--- a/tests/run-make/pgo-gen-lto/Makefile
+++ b/tests/run-make/pgo-gen-lto/Makefile
@@ -1,5 +1,6 @@
# needs-profiler-support
# ignore-windows-gnu
+# ignore-cross-compile
# FIXME(mati865): MinGW GCC miscompiles compiler-rt profiling library but with Clang it works
# properly. Since we only have GCC on the CI ignore the test for now.
diff --git a/tests/run-make/pgo-gen/Makefile b/tests/run-make/pgo-gen/Makefile
index 4623a7495..bf32cfdb8 100644
--- a/tests/run-make/pgo-gen/Makefile
+++ b/tests/run-make/pgo-gen/Makefile
@@ -1,5 +1,6 @@
# needs-profiler-support
# ignore-windows-gnu
+# ignore-cross-compile
# FIXME(mati865): MinGW GCC miscompiles compiler-rt profiling library but with Clang it works
# properly. Since we only have GCC on the CI ignore the test for now.
diff --git a/tests/run-make/pgo-indirect-call-promotion/Makefile b/tests/run-make/pgo-indirect-call-promotion/Makefile
index 45302215c..542eb244d 100644
--- a/tests/run-make/pgo-indirect-call-promotion/Makefile
+++ b/tests/run-make/pgo-indirect-call-promotion/Makefile
@@ -1,5 +1,6 @@
# needs-profiler-support
# ignore-windows-gnu
+# ignore-cross-compile
# FIXME(mati865): MinGW GCC miscompiles compiler-rt profiling library but with Clang it works
# properly. Since we only have GCC on the CI ignore the test for now.
diff --git a/tests/run-make/pgo-indirect-call-promotion/filecheck-patterns.txt b/tests/run-make/pgo-indirect-call-promotion/filecheck-patterns.txt
index e19c78350..2b058faaf 100644
--- a/tests/run-make/pgo-indirect-call-promotion/filecheck-patterns.txt
+++ b/tests/run-make/pgo-indirect-call-promotion/filecheck-patterns.txt
@@ -2,7 +2,7 @@ CHECK: define void @call_a_bunch_of_functions({{.*}} {
# Make sure that indirect call promotion inserted a check against the most
# frequently called function.
-CHECK: %{{.*}} = icmp eq {{void \(\)\*|ptr}} %{{.*}}, @function_called_always
+CHECK: %{{.*}} = icmp eq ptr %{{.*}}, @function_called_always
# Check that the call to `function_called_always` was inlined, so that we
# directly call `opaque_f1` from the upstream crate.
@@ -12,5 +12,5 @@ CHECK: call void @opaque_f1()
# Same checks as above, repeated for the trait object case
CHECK: define void @call_a_bunch_of_trait_methods({{.*}}
-CHECK: %{{.*}} = icmp eq {{void \(\{\}\*\)\*|ptr}} %{{.*}}, {{.*}}@foo
+CHECK: %{{.*}} = icmp eq ptr %{{.*}}, {{.*}}@foo
CHECK: tail call void @opaque_f2()
diff --git a/tests/run-make/pgo-use/Makefile b/tests/run-make/pgo-use/Makefile
index 3bac9b77a..9f440118d 100644
--- a/tests/run-make/pgo-use/Makefile
+++ b/tests/run-make/pgo-use/Makefile
@@ -1,5 +1,6 @@
# needs-profiler-support
# ignore-windows-gnu
+# ignore-cross-compile
# FIXME(mati865): MinGW GCC miscompiles compiler-rt profiling library but with Clang it works
# properly. Since we only have GCC on the CI ignore the test for now.
diff --git a/tests/run-make/pointer-auth-link-with-c/Makefile b/tests/run-make/pointer-auth-link-with-c/Makefile
index dffbd3035..8fcf10e20 100644
--- a/tests/run-make/pointer-auth-link-with-c/Makefile
+++ b/tests/run-make/pointer-auth-link-with-c/Makefile
@@ -1,6 +1,7 @@
include ../tools.mk
# only-aarch64
+# ignore-cross-compile
all:
$(COMPILE_OBJ) $(TMPDIR)/test.o test.c
diff --git a/tests/run-make/pretty-print-with-dep-file/Makefile b/tests/run-make/pretty-print-with-dep-file/Makefile
new file mode 100644
index 000000000..fa8089eb6
--- /dev/null
+++ b/tests/run-make/pretty-print-with-dep-file/Makefile
@@ -0,0 +1,9 @@
+include ../tools.mk
+
+all:
+ $(RUSTC) --emit=dep-info -Zunpretty=expanded with-dep.rs
+ $(CGREP) "with-dep.rs" < $(TMPDIR)/with-dep.d
+ -rm $(TMPDIR)/with-dep.d
+
+ $(RUSTC) --emit=dep-info -Zunpretty=normal with-dep.rs
+ ! test -f $(TMPDIR)/with-dep.d
diff --git a/tests/run-make/pretty-print-with-dep-file/with-dep.rs b/tests/run-make/pretty-print-with-dep-file/with-dep.rs
new file mode 100644
index 000000000..f328e4d9d
--- /dev/null
+++ b/tests/run-make/pretty-print-with-dep-file/with-dep.rs
@@ -0,0 +1 @@
+fn main() {}
diff --git a/tests/run-make/print-cfg/Makefile b/tests/run-make/print-cfg/Makefile
index 126f5768c..6b153e5b5 100644
--- a/tests/run-make/print-cfg/Makefile
+++ b/tests/run-make/print-cfg/Makefile
@@ -2,7 +2,7 @@
include ../tools.mk
-all: default
+all: default output_to_file
$(RUSTC) --target x86_64-pc-windows-gnu --print cfg | $(CGREP) windows
$(RUSTC) --target x86_64-pc-windows-gnu --print cfg | $(CGREP) x86_64
$(RUSTC) --target i686-pc-windows-msvc --print cfg | $(CGREP) msvc
@@ -11,6 +11,23 @@ all: default
$(RUSTC) --target arm-unknown-linux-gnueabihf --print cfg | $(CGREP) target_abi=
$(RUSTC) --target arm-unknown-linux-gnueabihf --print cfg | $(CGREP) eabihf
+output_to_file:
+ # Backend-independent, printed by rustc_driver_impl/src/lib.rs
+ $(RUSTC) --target x86_64-pc-windows-gnu --print cfg=$(TMPDIR)/cfg.txt
+ $(CGREP) windows < $(TMPDIR)/cfg.txt
+
+ # Printed from CodegenBackend trait impl in rustc_codegen_llvm/src/lib.rs
+ $(RUSTC) --print relocation-models=$(TMPDIR)/relocation-models.txt
+ $(CGREP) dynamic-no-pic < $(TMPDIR)/relocation-models.txt
+
+ # Printed by compiler/rustc_codegen_llvm/src/llvm_util.rs
+ $(RUSTC) --target wasm32-unknown-unknown --print target-features=$(TMPDIR)/target-features.txt
+ $(CGREP) reference-types < $(TMPDIR)/target-features.txt
+
+ # Printed by C++ code in rustc_llvm/llvm-wrapper/PassWrapper.cpp
+ $(RUSTC) --target wasm32-unknown-unknown --print target-cpus=$(TMPDIR)/target-cpus.txt
+ $(CGREP) generic < $(TMPDIR)/target-cpus.txt
+
ifdef IS_WINDOWS
default:
$(RUSTC) --print cfg | $(CGREP) windows
diff --git a/tests/run-make/print-native-static-libs/Makefile b/tests/run-make/print-native-static-libs/Makefile
index 98e72d769..a16c8b0f2 100644
--- a/tests/run-make/print-native-static-libs/Makefile
+++ b/tests/run-make/print-native-static-libs/Makefile
@@ -5,7 +5,7 @@ include ../tools.mk
all:
$(RUSTC) --crate-type rlib -lbar_cli bar.rs
- $(RUSTC) foo.rs -lfoo_cli --crate-type staticlib --print native-static-libs 2>&1 \
+ $(RUSTC) foo.rs -lfoo_cli -lfoo_cli --crate-type staticlib --print native-static-libs 2>&1 \
| grep 'note: native-static-libs: ' \
| sed 's/note: native-static-libs: \(.*\)/\1/' > $(TMPDIR)/libs.txt
@@ -13,3 +13,7 @@ all:
cat $(TMPDIR)/libs.txt | grep -F "systemd" # in foo.rs
cat $(TMPDIR)/libs.txt | grep -F "bar_cli"
cat $(TMPDIR)/libs.txt | grep -F "foo_cli"
+
+ # make sure that foo_cli and glib-2.0 are not consecutively present
+ cat $(TMPDIR)/libs.txt | grep -Fv "foo_cli -lfoo_cli"
+ cat $(TMPDIR)/libs.txt | grep -Fv "glib-2.0 -lglib-2.0"
diff --git a/tests/run-make/print-native-static-libs/bar.rs b/tests/run-make/print-native-static-libs/bar.rs
index a563bbc2a..cd9c1c453 100644
--- a/tests/run-make/print-native-static-libs/bar.rs
+++ b/tests/run-make/print-native-static-libs/bar.rs
@@ -3,6 +3,7 @@ pub extern "C" fn my_bar_add(left: i32, right: i32) -> i32 {
// Obviously makes no sense but...
unsafe {
g_free(std::ptr::null_mut());
+ g_free2(std::ptr::null_mut());
}
left + right
}
@@ -11,3 +12,8 @@ pub extern "C" fn my_bar_add(left: i32, right: i32) -> i32 {
extern "C" {
fn g_free(p: *mut ());
}
+
+#[link(name = "glib-2.0")]
+extern "C" {
+ fn g_free2(p: *mut ());
+}
diff --git a/tests/run-make/profile/Makefile b/tests/run-make/profile/Makefile
index fffc051ad..7919b18ba 100644
--- a/tests/run-make/profile/Makefile
+++ b/tests/run-make/profile/Makefile
@@ -1,4 +1,5 @@
# needs-profiler-support
+# ignore-cross-compile
include ../tools.mk
diff --git a/tests/run-make/raw-dylib-alt-calling-convention/Makefile b/tests/run-make/raw-dylib-alt-calling-convention/Makefile
index 1744c431f..14d23a5d2 100644
--- a/tests/run-make/raw-dylib-alt-calling-convention/Makefile
+++ b/tests/run-make/raw-dylib-alt-calling-convention/Makefile
@@ -16,17 +16,9 @@ else
endif
"$(TMPDIR)"/driver > "$(TMPDIR)"/output.txt
-ifdef RUSTC_BLESS_TEST
- cp "$(TMPDIR)"/output.txt output.txt
-else
- $(DIFF) output.txt "$(TMPDIR)"/output.txt
-endif
+ $(RUSTC_TEST_OP) "$(TMPDIR)"/output.txt output.txt
ifdef IS_MSVC
"$(TMPDIR)"/driver true > "$(TMPDIR)"/output.msvc.txt
-ifdef RUSTC_BLESS_TEST
- cp "$(TMPDIR)"/output.msvc.txt output.msvc.txt
-else
- $(DIFF) output.msvc.txt "$(TMPDIR)"/output.msvc.txt
-endif
+ $(RUSTC_TEST_OP) "$(TMPDIR)"/output.msvc.txt output.msvc.txt
endif
diff --git a/tests/run-make/raw-dylib-import-name-type/Makefile b/tests/run-make/raw-dylib-import-name-type/Makefile
index 671523298..901d3e861 100644
--- a/tests/run-make/raw-dylib-import-name-type/Makefile
+++ b/tests/run-make/raw-dylib-import-name-type/Makefile
@@ -14,9 +14,4 @@ else
$(CC) "$(TMPDIR)"/extern.obj extern.gnu.def --no-leading-underscore -shared -o "$(TMPDIR)"/extern.dll
endif
"$(TMPDIR)"/driver > "$(TMPDIR)"/output.txt
-
-ifdef RUSTC_BLESS_TEST
- cp "$(TMPDIR)"/output.txt output.txt
-else
- $(DIFF) output.txt "$(TMPDIR)"/output.txt
-endif
+ $(RUSTC_TEST_OP) "$(TMPDIR)"/output.txt output.txt
diff --git a/tests/run-make/raw-dylib-inline-cross-dylib/Makefile b/tests/run-make/raw-dylib-inline-cross-dylib/Makefile
index 6d1d04bfd..195b5fda5 100644
--- a/tests/run-make/raw-dylib-inline-cross-dylib/Makefile
+++ b/tests/run-make/raw-dylib-inline-cross-dylib/Makefile
@@ -27,9 +27,4 @@ else
$(CC) "$(TMPDIR)"/extern_2.obj -shared -o "$(TMPDIR)"/extern_2.dll
endif
$(call RUN,driver) > "$(TMPDIR)"/output.txt
-
-ifdef RUSTC_BLESS_TEST
- cp "$(TMPDIR)"/output.txt output.txt
-else
- $(DIFF) output.txt "$(TMPDIR)"/output.txt
-endif
+ $(RUSTC_TEST_OP) "$(TMPDIR)"/output.txt output.txt
diff --git a/tests/run-make/raw-dylib-link-ordinal/Makefile b/tests/run-make/raw-dylib-link-ordinal/Makefile
index 374a0b59d..49e959cdb 100644
--- a/tests/run-make/raw-dylib-link-ordinal/Makefile
+++ b/tests/run-make/raw-dylib-link-ordinal/Makefile
@@ -14,9 +14,4 @@ else
$(CC) "$(TMPDIR)"/exporter.obj exporter.def -shared -o "$(TMPDIR)"/exporter.dll
endif
"$(TMPDIR)"/driver > "$(TMPDIR)"/output.txt
-
-ifdef RUSTC_BLESS_TEST
- cp "$(TMPDIR)"/output.txt output.txt
-else
- $(DIFF) output.txt "$(TMPDIR)"/output.txt
-endif
+ $(RUSTC_TEST_OP) "$(TMPDIR)"/output.txt output.txt
diff --git a/tests/run-make/raw-dylib-stdcall-ordinal/Makefile b/tests/run-make/raw-dylib-stdcall-ordinal/Makefile
index 178c15ab3..70e4de62c 100644
--- a/tests/run-make/raw-dylib-stdcall-ordinal/Makefile
+++ b/tests/run-make/raw-dylib-stdcall-ordinal/Makefile
@@ -15,9 +15,4 @@ else
$(CC) "$(TMPDIR)"/exporter.obj exporter-gnu.def -shared -o "$(TMPDIR)"/exporter.dll
endif
"$(TMPDIR)"/driver > "$(TMPDIR)"/actual_output.txt
-
-ifdef RUSTC_BLESS_TEST
- cp "$(TMPDIR)"/actual_output.txt expected_output.txt
-else
- $(DIFF) expected_output.txt "$(TMPDIR)"/actual_output.txt
-endif
+ $(RUSTC_TEST_OP) "$(TMPDIR)"/actual_output.txt expected_output.txt
diff --git a/tests/run-make/remap-path-prefix-dwarf/Makefile b/tests/run-make/remap-path-prefix-dwarf/Makefile
index c9ede1b60..8905a00ea 100644
--- a/tests/run-make/remap-path-prefix-dwarf/Makefile
+++ b/tests/run-make/remap-path-prefix-dwarf/Makefile
@@ -3,17 +3,26 @@
# ignore-windows
+include ../tools.mk
+
SRC_DIR := $(abspath .)
SRC_DIR_PARENT := $(abspath ..)
-include ../tools.mk
+ifeq ($(UNAME),Darwin)
+ DEBUGINFOOPTS := -Csplit-debuginfo=off
+else
+ DEBUGINFOOPTS :=
+endif
all: \
abs_input_outside_working_dir \
rel_input_remap_working_dir \
+ rel_input_remap_working_dir_scope \
rel_input_remap_working_dir_parent \
rel_input_remap_working_dir_child \
+ rel_input_remap_working_dir_diagnostics \
abs_input_inside_working_dir \
+ abs_input_inside_working_dir_scope \
abs_input_outside_working_dir
# The compiler is called with an *ABSOLUTE PATH* as input, and that absolute path *is* within
@@ -27,6 +36,17 @@ abs_input_inside_working_dir:
# No weird duplication of remapped components (see #78479)
"$(LLVM_BIN_DIR)"/llvm-dwarfdump $(TMPDIR)/abs_input_inside_working_dir.rlib | $(CGREP) -v "REMAPPED/REMAPPED"
+# The compiler is called with an *ABSOLUTE PATH* as input, and that absolute path *is* within
+# the working directory of the compiler. We are remapping the path that contains `src`.
+abs_input_inside_working_dir_scope:
+ # We explicitly switch to a directory that *is* a prefix of the directory our
+ # source code is contained in.
+ cd $(SRC_DIR) && $(RUSTC) $(SRC_DIR)/src/quux.rs -o "$(TMPDIR)/abs_input_inside_working_dir_scope.rlib" -Cdebuginfo=2 --remap-path-prefix $(SRC_DIR)=REMAPPED -Zremap-path-scope=object $(DEBUGINFOOPTS)
+ # We expect the path to the main source file to be remapped.
+ "$(LLVM_BIN_DIR)"/llvm-dwarfdump $(TMPDIR)/abs_input_inside_working_dir_scope.rlib | $(CGREP) "REMAPPED/src/quux.rs"
+ # No weird duplication of remapped components (see #78479)
+ "$(LLVM_BIN_DIR)"/llvm-dwarfdump $(TMPDIR)/abs_input_inside_working_dir_scope.rlib | $(CGREP) -v "REMAPPED/REMAPPED"
+
# The compiler is called with an *ABSOLUTE PATH* as input, and that absolute path is *not* within
# the working directory of the compiler. We are remapping both the path that contains `src` and
# the working directory to the same thing. This setup corresponds to a workaround that is needed
@@ -52,6 +72,21 @@ rel_input_remap_working_dir:
# No weird duplication of remapped components (see #78479)
"$(LLVM_BIN_DIR)"/llvm-dwarfdump "$(TMPDIR)/rel_input_remap_working_dir.rlib" | $(CGREP) -v "REMAPPED/REMAPPED"
+# The compiler is called with a *RELATIVE PATH* as input. We are remapping the working directory of
+# the compiler, which naturally is an implicit prefix of our relative input path. Debuginfo will
+# expand the relative path to an absolute path and we expect the working directory to be remapped
+# in that expansion.
+rel_input_remap_working_dir_scope:
+ cd $(SRC_DIR) && $(RUSTC) src/quux.rs -o "$(TMPDIR)/rel_input_remap_working_dir_scope.rlib" -Cdebuginfo=2 --remap-path-prefix "$(SRC_DIR)=REMAPPED" -Zremap-path-scope=object $(DEBUGINFOOPTS)
+ "$(LLVM_BIN_DIR)"/llvm-dwarfdump "$(TMPDIR)/rel_input_remap_working_dir_scope.rlib" | $(CGREP) "REMAPPED/src/quux.rs"
+ # No weird duplication of remapped components (see #78479)
+ "$(LLVM_BIN_DIR)"/llvm-dwarfdump "$(TMPDIR)/rel_input_remap_working_dir_scope.rlib" | $(CGREP) -v "REMAPPED/REMAPPED"
+
+rel_input_remap_working_dir_diagnostics:
+ cd $(SRC_DIR) && $(RUSTC) src/quux.rs -o "$(TMPDIR)/rel_input_remap_working_dir_scope.rlib" -Cdebuginfo=2 --remap-path-prefix "$(SRC_DIR)=REMAPPED" -Zremap-path-scope=diagnostics $(DEBUGINFOOPTS)
+ "$(LLVM_BIN_DIR)"/llvm-dwarfdump "$(TMPDIR)/rel_input_remap_working_dir_scope.rlib" | $(CGREP) -v "REMAPPED/src/quux.rs"
+ "$(LLVM_BIN_DIR)"/llvm-dwarfdump "$(TMPDIR)/rel_input_remap_working_dir_scope.rlib" | $(CGREP) -v "REMAPPED/REMAPPED"
+
# The compiler is called with a *RELATIVE PATH* as input. We are remapping a *SUB-DIRECTORY* of the
# compiler's working directory. This test makes sure that that directory is remapped even though it
# won't actually show up in this form in the compiler's SourceMap and instead is only constructed
diff --git a/tests/run-make/remap-path-prefix/Makefile b/tests/run-make/remap-path-prefix/Makefile
index 2a7378fdf..35f65240f 100644
--- a/tests/run-make/remap-path-prefix/Makefile
+++ b/tests/run-make/remap-path-prefix/Makefile
@@ -2,8 +2,38 @@ include ../tools.mk
# ignore-windows
+ifeq ($(UNAME),Darwin)
+ DEBUGINFOOPTS := -Csplit-debuginfo=off
+else
+ DEBUGINFOOPTS :=
+endif
+
+all: remap remap-with-scope
+
# Checks if remapping works if the remap-from string contains path to the working directory plus more
-all:
+remap:
$(RUSTC) --remap-path-prefix $$PWD/auxiliary=/the/aux --crate-type=lib --emit=metadata auxiliary/lib.rs
grep "/the/aux/lib.rs" $(TMPDIR)/liblib.rmeta || exit 1
! grep "$$PWD/auxiliary" $(TMPDIR)/liblib.rmeta || exit 1
+
+remap-with-scope:
+ $(RUSTC) --remap-path-prefix $$PWD/auxiliary=/the/aux -Zremap-path-scope=object $(DEBUGINFOOPTS) --crate-type=lib --emit=metadata auxiliary/lib.rs
+ grep "/the/aux/lib.rs" $(TMPDIR)/liblib.rmeta || exit 1
+ ! grep "$$PWD/auxiliary" $(TMPDIR)/liblib.rmeta || exit 1
+
+ $(RUSTC) --remap-path-prefix $$PWD/auxiliary=/the/aux -Zremap-path-scope=diagnostics $(DEBUGINFOOPTS) --crate-type=lib --emit=metadata auxiliary/lib.rs
+ ! grep "/the/aux/lib.rs" $(TMPDIR)/liblib.rmeta || exit 1
+ grep "$$PWD/auxiliary" $(TMPDIR)/liblib.rmeta || exit 1
+
+ $(RUSTC) --remap-path-prefix $$PWD/auxiliary=/the/aux -Zremap-path-scope=diagnostics,object $(DEBUGINFOOPTS) --crate-type=lib --emit=metadata auxiliary/lib.rs
+ grep "/the/aux/lib.rs" $(TMPDIR)/liblib.rmeta || exit 1
+ ! grep "$$PWD/auxiliary" $(TMPDIR)/liblib.rmeta || exit 1
+
+ $(RUSTC) --remap-path-prefix $$PWD/auxiliary=/the/aux -Zremap-path-scope=split-debuginfo $(DEBUGINFOOPTS) --crate-type=lib --emit=metadata auxiliary/lib.rs
+ ! grep "/the/aux/lib.rs" $(TMPDIR)/liblib.rmeta || exit 1
+ grep "$$PWD/auxiliary" $(TMPDIR)/liblib.rmeta || exit 1
+
+ # FIXME: We should test the split debuginfo files, but we don't currently a good infra for that
+ $(RUSTC) --remap-path-prefix $$PWD/auxiliary=/the/aux -Zremap-path-scope=split-debuginfo -Zunstable-options -Csplit-debuginfo=packed --crate-type=lib --emit=metadata auxiliary/lib.rs
+ grep "/the/aux/lib.rs" $(TMPDIR)/liblib.rmeta || exit 1
+ ! grep "$$PWD/auxiliary" $(TMPDIR)/liblib.rmeta || exit 1
diff --git a/tests/run-make/rlib-format-packed-bundled-libs-3/Makefile b/tests/run-make/rlib-format-packed-bundled-libs-3/Makefile
index 1f2812cb0..9ba077b18 100644
--- a/tests/run-make/rlib-format-packed-bundled-libs-3/Makefile
+++ b/tests/run-make/rlib-format-packed-bundled-libs-3/Makefile
@@ -3,7 +3,7 @@ include ../tools.mk
# ignore-cross-compile
# only-linux
-# Make sure -Zpacked_bundled_libs-like behavior activates with whole-archive.
+# Make sure -Zpacked_bundled_libs-like behavior activates with +bundle,+whole-archive.
# We're using the llvm-nm instead of the system nm to ensure it is compatible
# with the LLVM bitcode generated by rustc.
@@ -11,7 +11,7 @@ NM = "$(LLVM_BIN_DIR)"/llvm-nm
all: $(call NATIVE_STATICLIB,native_dep_1) $(call NATIVE_STATICLIB,native_dep_2) $(call NATIVE_STATICLIB,native_dep_3) $(call NATIVE_STATICLIB,native_dep_4)
# test cfg with packed bundle
- $(RUSTC) rust_dep_cfg.rs --crate-type=rlib -Zpacked_bundled_libs
+ $(RUSTC) rust_dep_cfg.rs --crate-type=rlib
$(RUSTC) main.rs --extern rust_dep=$(TMPDIR)/librust_dep_cfg.rlib --crate-type=staticlib --cfg should_add
$(AR) t $(TMPDIR)/librust_dep_cfg.rlib | $(CGREP) -e "libnative_dep_1.a"
$(AR) t $(TMPDIR)/librust_dep_cfg.rlib | $(CGREP) -e "libnative_dep_2.a"
diff --git a/tests/run-make/rlib-format-packed-bundled-libs-3/rust_dep.rs b/tests/run-make/rlib-format-packed-bundled-libs-3/rust_dep.rs
index abd846b68..bde9b739d 100644
--- a/tests/run-make/rlib-format-packed-bundled-libs-3/rust_dep.rs
+++ b/tests/run-make/rlib-format-packed-bundled-libs-3/rust_dep.rs
@@ -1,5 +1,3 @@
-#![feature(packed_bundled_libs)]
-
#[link(name = "native_dep_1", kind = "static", modifiers = "+whole-archive,+bundle")]
extern "C" {}
diff --git a/tests/run-make/rmeta-preferred/Makefile b/tests/run-make/rmeta-preferred/Makefile
new file mode 100644
index 000000000..3bf12cced
--- /dev/null
+++ b/tests/run-make/rmeta-preferred/Makefile
@@ -0,0 +1,16 @@
+# ignore-cross-compile
+include ../tools.mk
+
+# 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).
+
+all:
+ $(RUSTC) rmeta_aux.rs --crate-type=rlib --emit link,metadata
+ $(RUSTC) lib.rs --crate-type=rlib --emit dep-info -Zbinary-dep-depinfo
+ $(CGREP) "librmeta_aux.rmeta" < $(TMPDIR)/lib.d
+ $(CGREP) -v "librmeta_aux.rlib" < $(TMPDIR)/lib.d
diff --git a/tests/run-make/rmeta-preferred/lib.rs b/tests/run-make/rmeta-preferred/lib.rs
new file mode 100644
index 000000000..d0b81a062
--- /dev/null
+++ b/tests/run-make/rmeta-preferred/lib.rs
@@ -0,0 +1,14 @@
+// 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).
+
+extern crate rmeta_aux;
+use rmeta_aux::Foo;
+
+pub fn foo() {
+ let _ = Foo { field: 42 };
+}
diff --git a/tests/run-make/rmeta-preferred/rmeta_aux.rs b/tests/run-make/rmeta-preferred/rmeta_aux.rs
new file mode 100644
index 000000000..3f7a12b50
--- /dev/null
+++ b/tests/run-make/rmeta-preferred/rmeta_aux.rs
@@ -0,0 +1,3 @@
+pub struct Foo {
+ pub field: i32,
+}
diff --git a/tests/run-make/rust-lld-custom-target/Makefile b/tests/run-make/rust-lld-custom-target/Makefile
new file mode 100644
index 000000000..007493ab0
--- /dev/null
+++ b/tests/run-make/rust-lld-custom-target/Makefile
@@ -0,0 +1,7 @@
+include ../tools.mk
+
+# needs-rust-lld
+# only-x86_64-unknown-linux-gnu
+all:
+ RUSTC_LOG=rustc_codegen_ssa::back::link=info $(RUSTC) --crate-type cdylib --target custom-target.json -Clink-args=-Wl,-v lib.rs 2> $(TMPDIR)/output.txt
+ $(CGREP) -e "^LLD [0-9]+\.[0-9]+\.[0-9]+" < $(TMPDIR)/output.txt
diff --git a/tests/run-make/rust-lld-custom-target/custom-target.json b/tests/run-make/rust-lld-custom-target/custom-target.json
new file mode 100644
index 000000000..7828a99f2
--- /dev/null
+++ b/tests/run-make/rust-lld-custom-target/custom-target.json
@@ -0,0 +1,57 @@
+{
+ "arch": "x86_64",
+ "cpu": "x86-64",
+ "crt-static-respected": true,
+ "data-layout": "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128",
+ "dynamic-linking": true,
+ "env": "gnu",
+ "has-rpath": true,
+ "has-thread-local": true,
+ "link-self-contained": {
+ "components": [
+ "linker"
+ ]
+ },
+ "linker-flavor": "gnu-lld-cc",
+ "llvm-target": "x86_64-unknown-linux-gnu",
+ "max-atomic-width": 64,
+ "os": "linux",
+ "plt-by-default": false,
+ "position-independent-executables": true,
+ "pre-link-args": {
+ "gnu-cc": [
+ "-m64"
+ ],
+ "gnu-lld-cc": [
+ "-m64"
+ ]
+ },
+ "relro-level": "full",
+ "stack-probes": {
+ "kind": "inline-or-call",
+ "min-llvm-version-for-inline": [
+ 16,
+ 0,
+ 0
+ ]
+ },
+ "static-position-independent-executables": true,
+ "supported-sanitizers": [
+ "address",
+ "cfi",
+ "leak",
+ "memory",
+ "thread",
+ "safestack"
+ ],
+ "supported-split-debuginfo": [
+ "packed",
+ "unpacked",
+ "off"
+ ],
+ "supports-xray": true,
+ "target-family": [
+ "unix"
+ ],
+ "target-pointer-width": "64"
+}
diff --git a/tests/run-make/rust-lld-custom-target/lib.rs b/tests/run-make/rust-lld-custom-target/lib.rs
new file mode 100644
index 000000000..d8f5e3108
--- /dev/null
+++ b/tests/run-make/rust-lld-custom-target/lib.rs
@@ -0,0 +1,9 @@
+// Test linking using `cc` with `rust-lld`, using a custom target with features described in MCP 510
+// see https://github.com/rust-lang/compiler-team/issues/510 for more info:
+//
+// Starting from the `x86_64-unknown-linux-gnu` target spec, we add the following options:
+// - a linker-flavor using lld via a C compiler
+// - the self-contained linker component is enabled
+
+#![feature(no_core)]
+#![no_core]
diff --git a/tests/run-make/rust-lld/Makefile b/tests/run-make/rust-lld/Makefile
new file mode 100644
index 000000000..f8526530d
--- /dev/null
+++ b/tests/run-make/rust-lld/Makefile
@@ -0,0 +1,8 @@
+include ../tools.mk
+
+# ignore-msvc
+# needs-rust-lld
+# ignore-s390x lld does not yet support s390x as target
+all:
+ RUSTC_LOG=rustc_codegen_ssa::back::link=info $(RUSTC) -Clink-self-contained=+linker -Clinker-flavor=gnu-lld-cc -Zunstable-options -Clink-args=-Wl,-v main.rs 2> $(TMPDIR)/output.txt
+ $(CGREP) -e "^LLD [0-9]+\.[0-9]+\.[0-9]+" < $(TMPDIR)/output.txt
diff --git a/tests/run-make/rust-lld/main.rs b/tests/run-make/rust-lld/main.rs
new file mode 100644
index 000000000..bf159cd94
--- /dev/null
+++ b/tests/run-make/rust-lld/main.rs
@@ -0,0 +1,4 @@
+// Test linking using `cc` with `rust-lld`, using the unstable CLI described in MCP 510
+// see https://github.com/rust-lang/compiler-team/issues/510 for more info
+
+fn main() {}
diff --git a/tests/run-make/rustc-macro-dep-files/foo.rs b/tests/run-make/rustc-macro-dep-files/foo.rs
index 66db1a217..00b1c26d4 100644
--- a/tests/run-make/rustc-macro-dep-files/foo.rs
+++ b/tests/run-make/rustc-macro-dep-files/foo.rs
@@ -7,6 +7,6 @@ use proc_macro::TokenStream;
#[proc_macro_derive(A)]
pub fn derive(input: TokenStream) -> TokenStream {
let input = input.to_string();
- assert!(input.contains("struct A ;"));
+ assert!(input.contains("struct A;"));
"struct B;".parse().unwrap()
}
diff --git a/tests/run-make/rustdoc-map-file/validate_json.py b/tests/run-make/rustdoc-map-file/validate_json.py
index 5c14c90b7..912dea379 100755
--- a/tests/run-make/rustdoc-map-file/validate_json.py
+++ b/tests/run-make/rustdoc-map-file/validate_json.py
@@ -6,7 +6,7 @@ import json
def find_redirect_map_file(folder, errors):
- for root, dirs, files in os.walk(folder):
+ for root, _dirs, files in os.walk(folder):
for name in files:
if not name.endswith("redirect-map.json"):
continue
diff --git a/tests/run-make/rustdoc-themes/Makefile b/tests/run-make/rustdoc-themes/Makefile
index a6d9a43ad..a4980eb0b 100644
--- a/tests/run-make/rustdoc-themes/Makefile
+++ b/tests/run-make/rustdoc-themes/Makefile
@@ -5,6 +5,7 @@ include ../tools.mk
OUTPUT_DIR := "$(TMPDIR)/rustdoc-themes"
all:
- cp $(S)/src/librustdoc/html/static/css/themes/light.css $(TMPDIR)/test.css
+ awk '/Begin theme: light/ {in_theme=1;next} /End theme:/ {in_theme=0} { if (in_theme) print }' \
+ < '$(S)/src/librustdoc/html/static/css/noscript.css' > '$(TMPDIR)/test.css'
$(RUSTDOC) -o $(OUTPUT_DIR) foo.rs --theme $(TMPDIR)/test.css
$(HTMLDOCCK) $(OUTPUT_DIR) foo.rs
diff --git a/tests/run-make/rustdoc-themes/foo.rs b/tests/run-make/rustdoc-themes/foo.rs
index 995544aef..8b1e75b0a 100644
--- a/tests/run-make/rustdoc-themes/foo.rs
+++ b/tests/run-make/rustdoc-themes/foo.rs
@@ -1,4 +1,4 @@
// @has test.css
// @has foo/struct.Foo.html
-// @has - '//*[@id="rustdoc-vars"]/@data-themes' 'test'
+// @has - '//*[@name="rustdoc-vars"]/@data-themes' 'test'
pub struct Foo;
diff --git a/tests/run-make/short-ice/Makefile b/tests/run-make/short-ice/Makefile
index 4f33d5902..23006fc09 100644
--- a/tests/run-make/short-ice/Makefile
+++ b/tests/run-make/short-ice/Makefile
@@ -3,6 +3,7 @@ include ../tools.mk
# ignore-windows
export RUSTC := $(RUSTC_ORIGINAL)
+export LD_LIBRARY_PATH := $(HOST_RPATH_DIR)
export TMPDIR := $(TMPDIR)
all:
diff --git a/tests/run-make/short-ice/check.sh b/tests/run-make/short-ice/check.sh
index 96cd8fe86..56babd214 100644
--- a/tests/run-make/short-ice/check.sh
+++ b/tests/run-make/short-ice/check.sh
@@ -1,5 +1,5 @@
#!/bin/sh
-
+export RUSTC_ICE=0
RUST_BACKTRACE=1 $RUSTC src/lib.rs -Z treat-err-as-bug=1 1>$TMPDIR/rust-test-1.log 2>&1
RUST_BACKTRACE=full $RUSTC src/lib.rs -Z treat-err-as-bug=1 1>$TMPDIR/rust-test-2.log 2>&1
@@ -28,8 +28,8 @@ echo "rustc_query_count_full: $rustc_query_count_full"
## and marks are in pairs.
if [ $short -lt $full ] &&
[ $begin_count -eq $end_count ] &&
- [ $(($rustc_query_count + 10)) -lt $rustc_query_count_full ] &&
- [ $rustc_query_count_full -gt 10 ]; then
+ [ $(($rustc_query_count + 5)) -lt $rustc_query_count_full ] &&
+ [ $rustc_query_count_full -gt 5 ]; then
exit 0
else
exit 1
diff --git a/tests/run-make/silly-file-names/Makefile b/tests/run-make/silly-file-names/Makefile
new file mode 100644
index 000000000..e51266c08
--- /dev/null
+++ b/tests/run-make/silly-file-names/Makefile
@@ -0,0 +1,12 @@
+# ignore-cross-compile we need to execute the binary
+# ignore-windows we create files with < and > in their names
+
+include ../tools.mk
+
+all:
+ echo '"comes from a file with a name that begins with <"' > "$(TMPDIR)/<leading-lt"
+ echo '"comes from a file with a name that ends with >"' > "$(TMPDIR)/trailing-gt>"
+ cp silly-file-names.rs "$(TMPDIR)/silly-file-names.rs"
+ $(RUSTC) "$(TMPDIR)/silly-file-names.rs" -o "$(TMPDIR)/silly-file-names"
+ "$(TMPDIR)/silly-file-names" > "$(TMPDIR)/silly-file-names.run.stdout"
+ $(RUSTC_TEST_OP) "$(TMPDIR)/silly-file-names.run.stdout" silly-file-names.run.stdout
diff --git a/tests/run-make/silly-file-names/silly-file-names.rs b/tests/run-make/silly-file-names/silly-file-names.rs
new file mode 100644
index 000000000..a20082091
--- /dev/null
+++ b/tests/run-make/silly-file-names/silly-file-names.rs
@@ -0,0 +1,4 @@
+fn main() {
+ println!(include!("<leading-lt"));
+ println!(include!("trailing-gt>"));
+}
diff --git a/tests/run-make/silly-file-names/silly-file-names.run.stdout b/tests/run-make/silly-file-names/silly-file-names.run.stdout
new file mode 100644
index 000000000..fbc4c89e0
--- /dev/null
+++ b/tests/run-make/silly-file-names/silly-file-names.run.stdout
@@ -0,0 +1,2 @@
+comes from a file with a name that begins with <
+comes from a file with a name that ends with >
diff --git a/tests/run-make/split-debuginfo/Makefile b/tests/run-make/split-debuginfo/Makefile
index 71e014c1f..9e05c8dc1 100644
--- a/tests/run-make/split-debuginfo/Makefile
+++ b/tests/run-make/split-debuginfo/Makefile
@@ -104,7 +104,7 @@ packed-lto-single:
ls $(TMPDIR)/*.dwp && exit 1 || exit 0
rm $(TMPDIR)/libbaz.rlib
-packed-remapped: packed-remapped-split packed-remapped-single
+packed-remapped: packed-remapped-split packed-remapped-single packed-remapped-scope packed-remapped-wrong-scope
# - Debuginfo in `.dwo` files
# - `.o` and binary refer to remapped `.dwo` paths which do not exist
@@ -134,6 +134,36 @@ packed-remapped-single:
rm $(TMPDIR)/foo.dwp
rm $(TMPDIR)/$(call BIN,foo)
+# - Debuginfo in `.o` files
+# - `.o` and binary refer to remapped `.o` paths which do not exist
+# - `.o` deleted
+# - `.dwo` never created
+# - `.dwp` present
+packed-remapped-scope:
+ $(RUSTC) $(UNSTABLEOPTS) -C split-debuginfo=packed -C debuginfo=2 \
+ -Z split-dwarf-kind=single --remap-path-prefix $(TMPDIR)=/a \
+ -Z remap-path-scope=split-debuginfo-path foo.rs -g
+ objdump -Wi $(TMPDIR)/foo | grep DW_AT_GNU_dwo_name | (! grep $(TMPDIR)) || exit 1
+ ls $(TMPDIR)/*.o && exit 1 || exit 0
+ ls $(TMPDIR)/*.dwo && exit 1 || exit 0
+ rm $(TMPDIR)/foo.dwp
+ rm $(TMPDIR)/$(call BIN,foo)
+
+# - Debuginfo in `.o` files
+# - `.o` and binary refer to remapped `.o` paths which do not exist
+# - `.o` deleted
+# - `.dwo` never created
+# - `.dwp` present
+packed-remapped-wrong-scope:
+ $(RUSTC) $(UNSTABLEOPTS) -C split-debuginfo=packed -C debuginfo=2 \
+ -Z split-dwarf-kind=single --remap-path-prefix $(TMPDIR)=/a \
+ -Z remap-path-scope=macro foo.rs -g
+ objdump -Wi $(TMPDIR)/foo | grep DW_AT_GNU_dwo_name | (grep $(TMPDIR)) || exit 1
+ ls $(TMPDIR)/*.o && exit 1 || exit 0
+ ls $(TMPDIR)/*.dwo && exit 1 || exit 0
+ rm $(TMPDIR)/foo.dwp
+ rm $(TMPDIR)/$(call BIN,foo)
+
packed-crosscrate: packed-crosscrate-split packed-crosscrate-single
# - Debuginfo in `.dwo` files
@@ -230,7 +260,7 @@ unpacked-lto-single:
ls $(TMPDIR)/*.dwp && exit 1 || exit 0
rm $(TMPDIR)/libbaz.rlib
-unpacked-remapped: unpacked-remapped-split unpacked-remapped-single
+unpacked-remapped: unpacked-remapped-split unpacked-remapped-single unpacked-remapped-scope unpacked-remapped-wrong-scope
# - Debuginfo in `.dwo` files
# - `.o` and binary refer to remapped `.dwo` paths which do not exist
@@ -260,6 +290,36 @@ unpacked-remapped-single:
ls $(TMPDIR)/*.dwp && exit 1 || exit 0
rm $(TMPDIR)/$(call BIN,foo)
+# - Debuginfo in `.o` files
+# - `.o` and binary refer to remapped `.o` paths which do not exist
+# - `.o` present
+# - `.dwo` never created
+# - `.dwp` never created
+unpacked-remapped-scope:
+ $(RUSTC) $(UNSTABLEOPTS) -C split-debuginfo=unpacked -C debuginfo=2 \
+ -Z split-dwarf-kind=single --remap-path-prefix $(TMPDIR)=/a \
+ -Z remap-path-scope=split-debuginfo-path foo.rs -g
+ objdump -Wi $(TMPDIR)/foo | grep DW_AT_GNU_dwo_name | (! grep $(TMPDIR)) || exit 1
+ rm $(TMPDIR)/*.o
+ ls $(TMPDIR)/*.dwo && exit 1 || exit 0
+ ls $(TMPDIR)/*.dwp && exit 1 || exit 0
+ rm $(TMPDIR)/$(call BIN,foo)
+
+# - Debuginfo in `.o` files
+# - `.o` and binary refer to remapped `.o` paths which do not exist
+# - `.o` present
+# - `.dwo` never created
+# - `.dwp` never created
+unpacked-remapped-wrong-scope:
+ $(RUSTC) $(UNSTABLEOPTS) -C split-debuginfo=unpacked -C debuginfo=2 \
+ -Z split-dwarf-kind=single --remap-path-prefix $(TMPDIR)=/a \
+ -Z remap-path-scope=macro foo.rs -g
+ objdump -Wi $(TMPDIR)/foo | grep DW_AT_GNU_dwo_name | (grep $(TMPDIR)) || exit 1
+ rm $(TMPDIR)/*.o
+ ls $(TMPDIR)/*.dwo && exit 1 || exit 0
+ ls $(TMPDIR)/*.dwp && exit 1 || exit 0
+ rm $(TMPDIR)/$(call BIN,foo)
+
unpacked-crosscrate: unpacked-crosscrate-split unpacked-crosscrate-single
# - Debuginfo in `.dwo` files
diff --git a/tests/run-make/sysroot-crates-are-unstable/test.py b/tests/run-make/sysroot-crates-are-unstable/test.py
index cab4faa4e..45cfdd195 100644
--- a/tests/run-make/sysroot-crates-are-unstable/test.py
+++ b/tests/run-make/sysroot-crates-are-unstable/test.py
@@ -46,7 +46,7 @@ def check_lib(lib):
'--target', os.environ['TARGET'],
'--extern', '{}={}'.format(lib['name'], lib['path'])],
to_input=('extern crate {};'.format(lib['name'])).encode('utf-8'))
- if not 'use of unstable library feature' in '{}{}'.format(stdout, stderr):
+ if 'use of unstable library feature' not in '{}{}'.format(stdout, stderr):
print('crate {} "{}" is not unstable'.format(lib['name'], lib['path']))
print('{}{}'.format(stdout, stderr))
print('')
diff --git a/tests/run-make/target-specs/Makefile b/tests/run-make/target-specs/Makefile
index a33f5368e..62d5365a7 100644
--- a/tests/run-make/target-specs/Makefile
+++ b/tests/run-make/target-specs/Makefile
@@ -8,4 +8,5 @@ all:
RUST_TARGET_PATH=. $(RUSTC) foo.rs --target=my-x86_64-unknown-linux-gnu-platform --crate-type=lib --emit=asm
$(RUSTC) -Z unstable-options --target=my-awesome-platform.json --print target-spec-json > $(TMPDIR)/test-platform.json && $(RUSTC) -Z unstable-options --target=$(TMPDIR)/test-platform.json --print target-spec-json | diff -q $(TMPDIR)/test-platform.json -
$(RUSTC) foo.rs --target=definitely-not-builtin-target 2>&1 | $(CGREP) 'may not set is_builtin'
+ $(RUSTC) foo.rs --target=endianness-mismatch 2>&1 | $(CGREP) '"data-layout" claims architecture is little-endian'
$(RUSTC) foo.rs --target=mismatching-data-layout --crate-type=lib
diff --git a/tests/run-make/target-specs/endianness-mismatch.json b/tests/run-make/target-specs/endianness-mismatch.json
new file mode 100644
index 000000000..431053ea9
--- /dev/null
+++ b/tests/run-make/target-specs/endianness-mismatch.json
@@ -0,0 +1,11 @@
+{
+ "pre-link-args": {"gcc": ["-m64"]},
+ "data-layout": "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128",
+ "linker-flavor": "gcc",
+ "llvm-target": "x86_64-unknown-linux-gnu",
+ "target-endian": "big",
+ "target-pointer-width": "64",
+ "target-c-int-width": "32",
+ "arch": "x86_64",
+ "os": "linux"
+}
diff --git a/tests/run-make/tools.mk b/tests/run-make/tools.mk
index ea06b620c..1d4e91113 100644
--- a/tests/run-make/tools.mk
+++ b/tests/run-make/tools.mk
@@ -8,7 +8,7 @@ TARGET_RPATH_ENV = \
RUSTC_ORIGINAL := $(RUSTC)
BARE_RUSTC := $(HOST_RPATH_ENV) '$(RUSTC)'
BARE_RUSTDOC := $(HOST_RPATH_ENV) '$(RUSTDOC)'
-RUSTC := $(BARE_RUSTC) --out-dir $(TMPDIR) -L $(TMPDIR) $(RUSTFLAGS)
+RUSTC := $(BARE_RUSTC) --out-dir $(TMPDIR) -L $(TMPDIR) $(RUSTFLAGS) -Ainternal_features
RUSTDOC := $(BARE_RUSTDOC) -L $(TARGET_RPATH_DIR)
ifdef RUSTC_LINKER
RUSTC := $(RUSTC) -Clinker='$(RUSTC_LINKER)'
@@ -21,6 +21,28 @@ CGREP := "$(S)/src/etc/cat-and-grep.sh"
# diff with common flags for multi-platform diffs against text output
DIFF := diff -u --strip-trailing-cr
+# With RUSTC_TEST_OP you can elegantly support blessing of run-make tests. Do
+# like this in a Makefile recipe:
+#
+# "$(TMPDIR)"/your-test > "$(TMPDIR)"/your-test.run.stdout
+# $(RUSTC_TEST_OP) "$(TMPDIR)"/your-test.run.stdout your-test.run.stdout
+#
+# When running the test normally with
+#
+# ./x test tests/run-make/your-test
+#
+# the actual output will be diffed against the expected output. When running in
+# bless-mode with
+#
+# ./x test --bless tests/run-make/your-test
+#
+# the actual output will be blessed as the expected output.
+ifdef RUSTC_BLESS_TEST
+ RUSTC_TEST_OP = cp
+else
+ RUSTC_TEST_OP = $(DIFF)
+endif
+
# Some of the Rust CI platforms use `/bin/dash` to run `shell` script in
# Makefiles. Other platforms, including many developer platforms, default to
# `/bin/bash`. (In many cases, `make` is actually using `/bin/sh`, but `sh`
diff --git a/tests/run-make/unknown-mod-stdin/Makefile b/tests/run-make/unknown-mod-stdin/Makefile
new file mode 100644
index 000000000..313b0ba83
--- /dev/null
+++ b/tests/run-make/unknown-mod-stdin/Makefile
@@ -0,0 +1,8 @@
+# ignore-windows
+
+include ../tools.mk
+
+all:
+ echo 'mod unknown;' | $(RUSTC) --crate-type rlib - >$(TMPDIR)/unknown-mod.stdout 2>$(TMPDIR)/unknown-mod.stderr || echo "failed successfully"
+ $(RUSTC_TEST_OP) "$(TMPDIR)"/unknown-mod.stdout unknown-mod.stdout
+ $(RUSTC_TEST_OP) "$(TMPDIR)"/unknown-mod.stderr unknown-mod.stderr
diff --git a/tests/run-make/unknown-mod-stdin/unknown-mod.stderr b/tests/run-make/unknown-mod-stdin/unknown-mod.stderr
new file mode 100644
index 000000000..bdbaa3817
--- /dev/null
+++ b/tests/run-make/unknown-mod-stdin/unknown-mod.stderr
@@ -0,0 +1,12 @@
+error[E0583]: file not found for module `unknown`
+ --> <anon>:1:1
+ |
+1 | mod unknown;
+ | ^^^^^^^^^^^^
+ |
+ = help: to create the module `unknown`, create file "unknown.rs" or "unknown/mod.rs"
+ = note: if there is a `mod unknown` elsewhere in the crate already, import it with `use crate::...` instead
+
+error: aborting due to 1 previous error
+
+For more information about this error, try `rustc --explain E0583`.
diff --git a/tests/run-make/unknown-mod-stdin/unknown-mod.stdout b/tests/run-make/unknown-mod-stdin/unknown-mod.stdout
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/tests/run-make/unknown-mod-stdin/unknown-mod.stdout
diff --git a/tests/run-make/use-extern-for-plugins/Makefile b/tests/run-make/use-extern-for-plugins/Makefile
deleted file mode 100644
index b8ec7e8dc..000000000
--- a/tests/run-make/use-extern-for-plugins/Makefile
+++ /dev/null
@@ -1,17 +0,0 @@
-include ../tools.mk
-
-# ignore-freebsd
-# ignore-openbsd
-# ignore-solaris
-
-HOST := $(shell $(RUSTC) -vV | grep 'host:' | sed 's/host: //')
-ifeq ($(findstring i686,$(HOST)),i686)
-TARGET := $(subst i686,x86_64,$(HOST))
-else
-TARGET := $(subst x86_64,i686,$(HOST))
-endif
-
-all:
- $(RUSTC) foo.rs -C extra-filename=-host
- $(RUSTC) bar.rs -C extra-filename=-targ --target $(TARGET)
- $(RUSTC) baz.rs --extern a=$(TMPDIR)/liba-targ.rlib --target $(TARGET)
diff --git a/tests/run-make/use-extern-for-plugins/bar.rs b/tests/run-make/use-extern-for-plugins/bar.rs
deleted file mode 100644
index 704d21203..000000000
--- a/tests/run-make/use-extern-for-plugins/bar.rs
+++ /dev/null
@@ -1,9 +0,0 @@
-#![feature(no_core)]
-#![no_core]
-#![crate_type = "lib"]
-#![crate_name = "a"]
-
-#[macro_export]
-macro_rules! bar {
- () => ()
-}
diff --git a/tests/run-make/use-extern-for-plugins/baz.rs b/tests/run-make/use-extern-for-plugins/baz.rs
deleted file mode 100644
index 49a96a0c8..000000000
--- a/tests/run-make/use-extern-for-plugins/baz.rs
+++ /dev/null
@@ -1,8 +0,0 @@
-#![feature(no_core)]
-#![no_core]
-#![crate_type = "lib"]
-
-#[macro_use]
-extern crate a;
-
-bar!();
diff --git a/tests/run-make/use-extern-for-plugins/foo.rs b/tests/run-make/use-extern-for-plugins/foo.rs
deleted file mode 100644
index dffdc0798..000000000
--- a/tests/run-make/use-extern-for-plugins/foo.rs
+++ /dev/null
@@ -1,8 +0,0 @@
-#![no_std]
-#![crate_type = "lib"]
-#![crate_name = "a"]
-
-#[macro_export]
-macro_rules! foo {
- () => ()
-}
diff --git a/tests/run-make/valid-print-requests/valid-print-requests.stderr b/tests/run-make/valid-print-requests/valid-print-requests.stderr
index 4f57550c2..22bb102f9 100644
--- a/tests/run-make/valid-print-requests/valid-print-requests.stderr
+++ b/tests/run-make/valid-print-requests/valid-print-requests.stderr
@@ -1,2 +1,2 @@
-error: unknown print request `uwu`. Valid print requests are: `crate-name`, `file-names`, `sysroot`, `target-libdir`, `cfg`, `calling-conventions`, `target-list`, `target-cpus`, `target-features`, `relocation-models`, `code-models`, `tls-models`, `native-static-libs`, `stack-protector-strategies`, `target-spec-json`, `all-target-specs-json`, `link-args`, `split-debuginfo`, `deployment-target`
+error: unknown print request `uwu`. Valid print requests are: `all-target-specs-json`, `calling-conventions`, `cfg`, `code-models`, `crate-name`, `deployment-target`, `file-names`, `link-args`, `native-static-libs`, `relocation-models`, `split-debuginfo`, `stack-protector-strategies`, `sysroot`, `target-cpus`, `target-features`, `target-libdir`, `target-list`, `target-spec-json`, `tls-models`
diff --git a/tests/run-make/wasm-exceptions-nostd/Makefile b/tests/run-make/wasm-exceptions-nostd/Makefile
new file mode 100644
index 000000000..34755ec14
--- /dev/null
+++ b/tests/run-make/wasm-exceptions-nostd/Makefile
@@ -0,0 +1,12 @@
+include ../tools.mk
+
+# only-wasm32-bare
+
+# Add a few command line args to make exceptions work
+RUSTC := $(RUSTC) -C llvm-args=-wasm-enable-eh
+RUSTC := $(RUSTC) -C target-feature=+exception-handling
+RUSTC := $(RUSTC) -C panic=unwind
+
+all:
+ $(RUSTC) src/lib.rs --target wasm32-unknown-unknown
+ $(NODE) verify.mjs $(TMPDIR)/lib.wasm
diff --git a/tests/run-make/wasm-exceptions-nostd/src/arena_alloc.rs b/tests/run-make/wasm-exceptions-nostd/src/arena_alloc.rs
new file mode 100644
index 000000000..572d25330
--- /dev/null
+++ b/tests/run-make/wasm-exceptions-nostd/src/arena_alloc.rs
@@ -0,0 +1,67 @@
+use core::alloc::{GlobalAlloc, Layout};
+use core::cell::UnsafeCell;
+
+#[global_allocator]
+static ALLOCATOR: ArenaAllocator = ArenaAllocator::new();
+
+/// Very simple allocator which never deallocates memory
+///
+/// Based on the example from
+/// https://doc.rust-lang.org/stable/std/alloc/trait.GlobalAlloc.html
+pub struct ArenaAllocator {
+ arena: UnsafeCell<Arena>,
+}
+
+impl ArenaAllocator {
+ pub const fn new() -> Self {
+ Self {
+ arena: UnsafeCell::new(Arena::new()),
+ }
+ }
+}
+
+/// Safe because we are singlethreaded
+unsafe impl Sync for ArenaAllocator {}
+
+unsafe impl GlobalAlloc for ArenaAllocator {
+ unsafe fn alloc(&self, layout: Layout) -> *mut u8 {
+ let arena = &mut *self.arena.get();
+ arena.alloc(layout)
+ }
+
+ unsafe fn dealloc(&self, _ptr: *mut u8, _layout: Layout) {}
+}
+
+const ARENA_SIZE: usize = 64 * 1024; // more than enough
+
+#[repr(C, align(4096))]
+struct Arena {
+ buf: [u8; ARENA_SIZE], // aligned at 4096
+ allocated: usize,
+}
+
+impl Arena {
+ pub const fn new() -> Self {
+ Self {
+ buf: [0x55; ARENA_SIZE],
+ allocated: 0,
+ }
+ }
+
+ pub unsafe fn alloc(&mut self, layout: Layout) -> *mut u8 {
+ if layout.align() > 4096 || layout.size() > ARENA_SIZE {
+ return core::ptr::null_mut();
+ }
+
+ let align_minus_one = layout.align() - 1;
+ let start = (self.allocated + align_minus_one) & !align_minus_one; // round up
+ let new_cursor = start + layout.size();
+
+ if new_cursor >= ARENA_SIZE {
+ return core::ptr::null_mut();
+ }
+
+ self.allocated = new_cursor;
+ self.buf.as_mut_ptr().add(start)
+ }
+}
diff --git a/tests/run-make/wasm-exceptions-nostd/src/lib.rs b/tests/run-make/wasm-exceptions-nostd/src/lib.rs
new file mode 100644
index 000000000..7049d2fd9
--- /dev/null
+++ b/tests/run-make/wasm-exceptions-nostd/src/lib.rs
@@ -0,0 +1,60 @@
+#![no_std]
+#![crate_type = "cdylib"]
+
+// Allow a few unstable features because we create a panic
+// runtime for native wasm exceptions from scratch
+
+#![feature(core_intrinsics)]
+#![feature(lang_items)]
+#![feature(link_llvm_intrinsics)]
+#![feature(panic_info_message)]
+
+extern crate alloc;
+
+/// This module allows us to use `Box`, `String`, ... even in no-std
+mod arena_alloc;
+
+/// This module allows logging text, even in no-std
+mod logging;
+
+/// This module allows exceptions, even in no-std
+#[cfg(target_arch = "wasm32")]
+mod panicking;
+
+use alloc::boxed::Box;
+use alloc::string::String;
+
+struct LogOnDrop;
+
+impl Drop for LogOnDrop {
+ fn drop(&mut self) {
+ logging::log_str("Dropped");
+ }
+}
+
+#[allow(unreachable_code)]
+#[allow(unconditional_panic)]
+#[no_mangle]
+pub extern "C" fn start() -> usize {
+ let data = 0x1234usize as *mut u8; // Something to recognize
+
+ unsafe {
+ core::intrinsics::r#try(|data: *mut u8| {
+ let _log_on_drop = LogOnDrop;
+
+ logging::log_str(&alloc::format!("`r#try` called with ptr {:?}", data));
+ let x = [12];
+ let _ = x[4]; // should panic
+
+ logging::log_str("This line should not be visible! :(");
+ }, data, |data, exception| {
+ let exception = *Box::from_raw(exception as *mut String);
+ logging::log_str("Caught something!");
+ logging::log_str(&alloc::format!(" data : {:?}", data));
+ logging::log_str(&alloc::format!(" exception: {:?}", exception));
+ });
+ }
+
+ logging::log_str("This program terminates correctly.");
+ 0
+}
diff --git a/tests/run-make/wasm-exceptions-nostd/src/logging.rs b/tests/run-make/wasm-exceptions-nostd/src/logging.rs
new file mode 100644
index 000000000..569d03ec8
--- /dev/null
+++ b/tests/run-make/wasm-exceptions-nostd/src/logging.rs
@@ -0,0 +1,9 @@
+extern "C" {
+ fn __log_utf8(ptr: *const u8, size: usize);
+}
+
+pub fn log_str(text: &str) {
+ unsafe {
+ __log_utf8(text.as_ptr(), text.len());
+ }
+}
diff --git a/tests/run-make/wasm-exceptions-nostd/src/panicking.rs b/tests/run-make/wasm-exceptions-nostd/src/panicking.rs
new file mode 100644
index 000000000..4a8923fd4
--- /dev/null
+++ b/tests/run-make/wasm-exceptions-nostd/src/panicking.rs
@@ -0,0 +1,29 @@
+#[lang = "eh_personality"]
+fn eh_personality() {}
+
+mod internal {
+ extern "C" {
+ #[link_name = "llvm.wasm.throw"]
+ pub fn wasm_throw(tag: i32, ptr: *mut u8) -> !;
+ }
+}
+
+unsafe fn wasm_throw(ptr: *mut u8) -> ! {
+ internal::wasm_throw(0, ptr);
+}
+
+#[panic_handler]
+fn panic_handler(info: &core::panic::PanicInfo<'_>) -> ! {
+ use alloc::boxed::Box;
+ use alloc::string::ToString;
+
+ let msg = info
+ .message()
+ .map(|msg| msg.to_string())
+ .unwrap_or("(no message)".to_string());
+ let exception = Box::new(msg.to_string());
+ unsafe {
+ let exception_raw = Box::into_raw(exception);
+ wasm_throw(exception_raw as *mut u8);
+ }
+}
diff --git a/tests/run-make/wasm-exceptions-nostd/verify.mjs b/tests/run-make/wasm-exceptions-nostd/verify.mjs
new file mode 100644
index 000000000..e6c44d89d
--- /dev/null
+++ b/tests/run-make/wasm-exceptions-nostd/verify.mjs
@@ -0,0 +1,75 @@
+import fs from 'fs';
+
+const dec = new TextDecoder("utf-8");
+
+if (process.argv.length != 3) {
+ console.log("Usage: node verify.mjs <wasm-file>");
+ process.exit(0);
+}
+
+const wasmfile = process.argv[2];
+if (!fs.existsSync(wasmfile)) {
+ console.log("Error: File not found:", wasmfile);
+ process.exit(1);
+}
+
+const wasmBuffer = fs.readFileSync(wasmfile);
+
+async function main() {
+
+ let memory = new ArrayBuffer(0) // will be changed after instantiate
+
+ const captured_output = [];
+
+ const imports = {
+ env: {
+ __log_utf8: (ptr, size) => {
+ const str = dec.decode(new DataView(memory, ptr, size));
+ captured_output.push(str);
+ console.log(str);
+ }
+ }
+ };
+
+ const wasmModule = await WebAssembly.instantiate(wasmBuffer, imports);
+ memory = wasmModule.instance.exports.memory.buffer;
+
+ const start = wasmModule.instance.exports.start;
+ const return_code = start();
+
+ console.log("Return-Code:", return_code);
+
+ if (return_code !== 0) {
+ console.error("Expected return code 0");
+ process.exit(return_code);
+ }
+
+ const expected_output = [
+ '`r#try` called with ptr 0x1234',
+ 'Dropped',
+ 'Caught something!',
+ ' data : 0x1234',
+ ' exception: "index out of bounds: the len is 1 but the index is 4"',
+ 'This program terminates correctly.',
+ ];
+
+ assert_equal(captured_output, expected_output);
+}
+
+function assert_equal(captured_output, expected_output) {
+ if (captured_output.length != expected_output.length) {
+ console.error("Unexpected number of output lines. Got", captured_output.length, "but expected", expected_output.length);
+ process.exit(1); // exit with error
+ }
+
+ for (let idx = 0; idx < expected_output.length; ++idx) {
+ if (captured_output[idx] !== expected_output[idx]) {
+ console.error("Unexpected output");
+ console.error("[got] ", captured_output[idx]);
+ console.error("[expected]", expected_output[idx]);
+ process.exit(2); // exit with error
+ }
+ }
+}
+
+await main(); \ No newline at end of file
diff --git a/tests/run-make/wasm-override-linker/Makefile b/tests/run-make/wasm-override-linker/Makefile
new file mode 100644
index 000000000..52339f926
--- /dev/null
+++ b/tests/run-make/wasm-override-linker/Makefile
@@ -0,0 +1,13 @@
+# needs-matching-clang
+
+include ../tools.mk
+
+ifeq ($(TARGET),wasm32-unknown-unknown)
+all:
+ $(RUSTC) foo.rs --crate-type cdylib --target $(TARGET) -C linker=$(CLANG)
+else ifeq ($(TARGET),wasm64-unknown-unknown)
+all:
+ $(RUSTC) foo.rs --crate-type cdylib --target $(TARGET) -C linker=$(CLANG)
+else
+all:
+endif
diff --git a/tests/run-make/wasm-override-linker/foo.rs b/tests/run-make/wasm-override-linker/foo.rs
new file mode 100644
index 000000000..f4167a4fc
--- /dev/null
+++ b/tests/run-make/wasm-override-linker/foo.rs
@@ -0,0 +1,6 @@
+#![crate_type = "cdylib"]
+
+#[no_mangle]
+pub extern "C" fn add(a: i32, b: i32) -> i32 {
+ a + b
+}
diff --git a/tests/run-make/windows-safeseh/Makefile b/tests/run-make/windows-safeseh/Makefile
new file mode 100644
index 000000000..d6a403961
--- /dev/null
+++ b/tests/run-make/windows-safeseh/Makefile
@@ -0,0 +1,19 @@
+# only-windows
+# needs-rust-lld
+
+include ../tools.mk
+
+all: foo bar
+
+# Ensure that LLD can link when an .rlib contains a synthetic object
+# file referencing exported or used symbols.
+foo:
+ $(RUSTC) -C linker=rust-lld foo.rs
+
+# Ensure that LLD can link when /WHOLEARCHIVE: is used with an .rlib.
+# Previously, lib.rmeta was not marked as (trivially) SAFESEH-aware.
+bar: baz
+ $(RUSTC) -C linker=rust-lld -C link-arg=/WHOLEARCHIVE:libbaz.rlib bar.rs
+
+baz:
+ $(RUSTC) baz.rs
diff --git a/tests/run-make/windows-safeseh/bar.rs b/tests/run-make/windows-safeseh/bar.rs
new file mode 100644
index 000000000..f328e4d9d
--- /dev/null
+++ b/tests/run-make/windows-safeseh/bar.rs
@@ -0,0 +1 @@
+fn main() {}
diff --git a/tests/run-make/windows-safeseh/baz.rs b/tests/run-make/windows-safeseh/baz.rs
new file mode 100644
index 000000000..8d5b9dc5a
--- /dev/null
+++ b/tests/run-make/windows-safeseh/baz.rs
@@ -0,0 +1,4 @@
+#![crate_type = "rlib"]
+
+#[no_mangle]
+extern "C" fn baz() {}
diff --git a/tests/run-make/issue-96498/foo.rs b/tests/run-make/windows-safeseh/foo.rs
index 93ac3641b..93ac3641b 100644
--- a/tests/run-make/issue-96498/foo.rs
+++ b/tests/run-make/windows-safeseh/foo.rs
diff --git a/tests/run-make/x86_64-fortanix-unknown-sgx-lvi/print.checks b/tests/run-make/x86_64-fortanix-unknown-sgx-lvi/print.checks
index 8a5493650..e02fe0948 100644
--- a/tests/run-make/x86_64-fortanix-unknown-sgx-lvi/print.checks
+++ b/tests/run-make/x86_64-fortanix-unknown-sgx-lvi/print.checks
@@ -1,6 +1,6 @@
CHECK: print
CHECK: lfence
-CHECK: lfence
-CHECK: lfence
-CHECK: callq 0x{{[[:xdigit:]]*}} <_Unwind_Resume>
-CHECK-NEXT: ud2
+CHECK: popq
+CHECK-NEXT: popq [[REGISTER:%[a-z]+]]
+CHECK-NEXT: lfence
+CHECK-NEXT: jmpq *[[REGISTER]]
diff --git a/tests/run-make/x86_64-fortanix-unknown-sgx-lvi/script.sh b/tests/run-make/x86_64-fortanix-unknown-sgx-lvi/script.sh
index 235bb603b..04a347245 100644
--- a/tests/run-make/x86_64-fortanix-unknown-sgx-lvi/script.sh
+++ b/tests/run-make/x86_64-fortanix-unknown-sgx-lvi/script.sh
@@ -33,6 +33,15 @@ function check {
${objdump} --disassemble-symbols="${func}" --demangle \
${enclave} > ${asm}
${filecheck} --input-file ${asm} ${checks}
+
+ if [ "${func_re}" != "rust_plus_one_global_asm" &&
+ "${func_re}" != "cmake_plus_one_c_global_asm" ]; then
+ # The assembler cannot avoid explicit `ret` instructions. Sequences
+ # of `shlq $0x0, (%rsp); lfence; retq` are used instead.
+ # https://www.intel.com/content/www/us/en/developer/articles/technical/
+ # software-security-guidance/technical-documentation/load-value-injection.html
+ ${filecheck} --implicit-check-not ret --input-file ${asm} ${checks}
+ fi
}
build