From 86433e6ed1f28d1961d8316022277287330d71d1 Mon Sep 17 00:00:00 2001 From: Martin Nordholts Date: Wed, 26 Jul 2023 14:44:05 +0200 Subject: [PATCH 01/18] Add regression test for `echo 'mod unknown;' | rustc -` --- tests/run-make/unknown-mod-stdin/Makefile | 13 +++++++++++++ tests/run-make/unknown-mod-stdin/unknown-mod.stderr | 11 +++++++++++ tests/run-make/unknown-mod-stdin/unknown-mod.stdout | 0 3 files changed, 24 insertions(+) create mode 100644 tests/run-make/unknown-mod-stdin/Makefile create mode 100644 tests/run-make/unknown-mod-stdin/unknown-mod.stderr create mode 100644 tests/run-make/unknown-mod-stdin/unknown-mod.stdout diff --git a/tests/run-make/unknown-mod-stdin/Makefile b/tests/run-make/unknown-mod-stdin/Makefile new file mode 100644 index 0000000000000..6a73179c51fe3 --- /dev/null +++ b/tests/run-make/unknown-mod-stdin/Makefile @@ -0,0 +1,13 @@ +include ../tools.mk + +all: + echo 'mod unknown;' | $(RUSTC) --crate-type rlib - >$(TMPDIR)/unknown-mod.stdout 2>$(TMPDIR)/unknown-mod.stderr || echo "failed successfully" + +# Bless like this: RUSTC_BLESS_TEST=1 ./x.py test tests/run-make/unknown-mod-stdin +ifdef RUSTC_BLESS_TEST + cp "$(TMPDIR)"/unknown-mod.stdout unknown-mod.stdout + cp "$(TMPDIR)"/unknown-mod.stderr unknown-mod.stderr +else + $(DIFF) unknown-mod.stdout "$(TMPDIR)"/unknown-mod.stdout + $(DIFF) unknown-mod.stderr "$(TMPDIR)"/unknown-mod.stderr +endif 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 0000000000000..d7258fe4f68d8 --- /dev/null +++ b/tests/run-make/unknown-mod-stdin/unknown-mod.stderr @@ -0,0 +1,11 @@ +error[E0583]: file not found for module `unknown` + --> :1:1 + | +1 | mod unknown; + | ^^^^^^^^^^^^ + | + = help: to create the module `unknown`, create file "unknown.rs" or "unknown/mod.rs" + +error: aborting due to 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 0000000000000..e69de29bb2d1d From 0f534d06a82f7bd2bce2ddb036210956a198c01b Mon Sep 17 00:00:00 2001 From: Jubilee Young Date: Sat, 29 Jul 2023 17:05:04 -0700 Subject: [PATCH 02/18] tests/codegen/sanitizer{-,_}* -> sanitizer/* --- .../cfi-add-canonical-jump-tables-flag.rs} | 0 .../cfi-add-enable-split-lto-unit-flag.rs} | 0 .../cfi-emit-type-checks-attr-no-sanitize.rs} | 0 .../cfi-emit-type-checks.rs} | 0 .../cfi-emit-type-metadata-attr-cfi-encoding.rs} | 0 .../cfi-emit-type-metadata-id-itanium-cxx-abi.rs} | 0 .../cfi-emit-type-metadata-itanium-cxx-abi-generalized.rs} | 0 ...-emit-type-metadata-itanium-cxx-abi-normalized-generalized.rs} | 0 .../cfi-emit-type-metadata-itanium-cxx-abi-normalized.rs} | 0 .../cfi-emit-type-metadata-itanium-cxx-abi.rs} | 0 .../cfi-emit-type-metadata-trait-objects.rs} | 0 .../cfi-generalize-pointers.rs} | 0 .../cfi-normalize-integers.rs} | 0 .../kasan-emits-instrumentation.rs} | 0 .../kcfi-add-kcfi-flag.rs} | 0 .../kcfi-emit-kcfi-operand-bundle-attr-no-sanitize.rs} | 0 .../kcfi-emit-kcfi-operand-bundle-itanium-cxx-abi-generalized.rs} | 0 ...kcfi-operand-bundle-itanium-cxx-abi-normalized-generalized.rs} | 0 .../kcfi-emit-kcfi-operand-bundle-itanium-cxx-abi-normalized.rs} | 0 .../kcfi-emit-kcfi-operand-bundle-itanium-cxx-abi.rs} | 0 .../kcfi-emit-kcfi-operand-bundle.rs} | 0 .../kcfi-emit-type-metadata-trait-objects.rs} | 0 .../memory-track-origins.rs} | 0 .../memtag-attr-check.rs} | 0 .../no-sanitize-inlining.rs} | 0 .../{sanitizer-no-sanitize.rs => sanitizer/no-sanitize.rs} | 0 .../safestack-attr-check.rs} | 0 tests/codegen/{ => sanitizer}/sanitizer-recover.rs | 0 .../{sanitizer_scs_attr_check.rs => sanitizer/scs-attr-check.rs} | 0 29 files changed, 0 insertions(+), 0 deletions(-) rename tests/codegen/{sanitizer-cfi-add-canonical-jump-tables-flag.rs => sanitizer/cfi-add-canonical-jump-tables-flag.rs} (100%) rename tests/codegen/{sanitizer-cfi-add-enable-split-lto-unit-flag.rs => sanitizer/cfi-add-enable-split-lto-unit-flag.rs} (100%) rename tests/codegen/{sanitizer-cfi-emit-type-checks-attr-no-sanitize.rs => sanitizer/cfi-emit-type-checks-attr-no-sanitize.rs} (100%) rename tests/codegen/{sanitizer-cfi-emit-type-checks.rs => sanitizer/cfi-emit-type-checks.rs} (100%) rename tests/codegen/{sanitizer-cfi-emit-type-metadata-attr-cfi-encoding.rs => sanitizer/cfi-emit-type-metadata-attr-cfi-encoding.rs} (100%) rename tests/codegen/{sanitizer-cfi-emit-type-metadata-id-itanium-cxx-abi.rs => sanitizer/cfi-emit-type-metadata-id-itanium-cxx-abi.rs} (100%) rename tests/codegen/{sanitizer-cfi-emit-type-metadata-itanium-cxx-abi-generalized.rs => sanitizer/cfi-emit-type-metadata-itanium-cxx-abi-generalized.rs} (100%) rename tests/codegen/{sanitizer-cfi-emit-type-metadata-itanium-cxx-abi-normalized-generalized.rs => sanitizer/cfi-emit-type-metadata-itanium-cxx-abi-normalized-generalized.rs} (100%) rename tests/codegen/{sanitizer-cfi-emit-type-metadata-itanium-cxx-abi-normalized.rs => sanitizer/cfi-emit-type-metadata-itanium-cxx-abi-normalized.rs} (100%) rename tests/codegen/{sanitizer-cfi-emit-type-metadata-itanium-cxx-abi.rs => sanitizer/cfi-emit-type-metadata-itanium-cxx-abi.rs} (100%) rename tests/codegen/{sanitizer-cfi-emit-type-metadata-trait-objects.rs => sanitizer/cfi-emit-type-metadata-trait-objects.rs} (100%) rename tests/codegen/{sanitizer-cfi-generalize-pointers.rs => sanitizer/cfi-generalize-pointers.rs} (100%) rename tests/codegen/{sanitizer-cfi-normalize-integers.rs => sanitizer/cfi-normalize-integers.rs} (100%) rename tests/codegen/{sanitizer-kasan-emits-instrumentation.rs => sanitizer/kasan-emits-instrumentation.rs} (100%) rename tests/codegen/{sanitizer-kcfi-add-kcfi-flag.rs => sanitizer/kcfi-add-kcfi-flag.rs} (100%) rename tests/codegen/{sanitizer-kcfi-emit-kcfi-operand-bundle-attr-no-sanitize.rs => sanitizer/kcfi-emit-kcfi-operand-bundle-attr-no-sanitize.rs} (100%) rename tests/codegen/{sanitizer-kcfi-emit-kcfi-operand-bundle-itanium-cxx-abi-generalized.rs => sanitizer/kcfi-emit-kcfi-operand-bundle-itanium-cxx-abi-generalized.rs} (100%) rename tests/codegen/{sanitizer-kcfi-emit-kcfi-operand-bundle-itanium-cxx-abi-normalized-generalized.rs => sanitizer/kcfi-emit-kcfi-operand-bundle-itanium-cxx-abi-normalized-generalized.rs} (100%) rename tests/codegen/{sanitizer-kcfi-emit-kcfi-operand-bundle-itanium-cxx-abi-normalized.rs => sanitizer/kcfi-emit-kcfi-operand-bundle-itanium-cxx-abi-normalized.rs} (100%) rename tests/codegen/{sanitizer-kcfi-emit-kcfi-operand-bundle-itanium-cxx-abi.rs => sanitizer/kcfi-emit-kcfi-operand-bundle-itanium-cxx-abi.rs} (100%) rename tests/codegen/{sanitizer-kcfi-emit-kcfi-operand-bundle.rs => sanitizer/kcfi-emit-kcfi-operand-bundle.rs} (100%) rename tests/codegen/{sanitizer-kcfi-emit-type-metadata-trait-objects.rs => sanitizer/kcfi-emit-type-metadata-trait-objects.rs} (100%) rename tests/codegen/{sanitizer-memory-track-orgins.rs => sanitizer/memory-track-origins.rs} (100%) rename tests/codegen/{sanitizer_memtag_attr_check.rs => sanitizer/memtag-attr-check.rs} (100%) rename tests/codegen/{sanitizer-no-sanitize-inlining.rs => sanitizer/no-sanitize-inlining.rs} (100%) rename tests/codegen/{sanitizer-no-sanitize.rs => sanitizer/no-sanitize.rs} (100%) rename tests/codegen/{sanitizer-safestack-attr-check.rs => sanitizer/safestack-attr-check.rs} (100%) rename tests/codegen/{ => sanitizer}/sanitizer-recover.rs (100%) rename tests/codegen/{sanitizer_scs_attr_check.rs => sanitizer/scs-attr-check.rs} (100%) diff --git a/tests/codegen/sanitizer-cfi-add-canonical-jump-tables-flag.rs b/tests/codegen/sanitizer/cfi-add-canonical-jump-tables-flag.rs similarity index 100% rename from tests/codegen/sanitizer-cfi-add-canonical-jump-tables-flag.rs rename to tests/codegen/sanitizer/cfi-add-canonical-jump-tables-flag.rs diff --git a/tests/codegen/sanitizer-cfi-add-enable-split-lto-unit-flag.rs b/tests/codegen/sanitizer/cfi-add-enable-split-lto-unit-flag.rs similarity index 100% rename from tests/codegen/sanitizer-cfi-add-enable-split-lto-unit-flag.rs rename to tests/codegen/sanitizer/cfi-add-enable-split-lto-unit-flag.rs diff --git a/tests/codegen/sanitizer-cfi-emit-type-checks-attr-no-sanitize.rs b/tests/codegen/sanitizer/cfi-emit-type-checks-attr-no-sanitize.rs similarity index 100% rename from tests/codegen/sanitizer-cfi-emit-type-checks-attr-no-sanitize.rs rename to tests/codegen/sanitizer/cfi-emit-type-checks-attr-no-sanitize.rs diff --git a/tests/codegen/sanitizer-cfi-emit-type-checks.rs b/tests/codegen/sanitizer/cfi-emit-type-checks.rs similarity index 100% rename from tests/codegen/sanitizer-cfi-emit-type-checks.rs rename to tests/codegen/sanitizer/cfi-emit-type-checks.rs diff --git a/tests/codegen/sanitizer-cfi-emit-type-metadata-attr-cfi-encoding.rs b/tests/codegen/sanitizer/cfi-emit-type-metadata-attr-cfi-encoding.rs similarity index 100% rename from tests/codegen/sanitizer-cfi-emit-type-metadata-attr-cfi-encoding.rs rename to tests/codegen/sanitizer/cfi-emit-type-metadata-attr-cfi-encoding.rs diff --git a/tests/codegen/sanitizer-cfi-emit-type-metadata-id-itanium-cxx-abi.rs b/tests/codegen/sanitizer/cfi-emit-type-metadata-id-itanium-cxx-abi.rs similarity index 100% rename from tests/codegen/sanitizer-cfi-emit-type-metadata-id-itanium-cxx-abi.rs rename to tests/codegen/sanitizer/cfi-emit-type-metadata-id-itanium-cxx-abi.rs diff --git a/tests/codegen/sanitizer-cfi-emit-type-metadata-itanium-cxx-abi-generalized.rs b/tests/codegen/sanitizer/cfi-emit-type-metadata-itanium-cxx-abi-generalized.rs similarity index 100% rename from tests/codegen/sanitizer-cfi-emit-type-metadata-itanium-cxx-abi-generalized.rs rename to tests/codegen/sanitizer/cfi-emit-type-metadata-itanium-cxx-abi-generalized.rs diff --git a/tests/codegen/sanitizer-cfi-emit-type-metadata-itanium-cxx-abi-normalized-generalized.rs b/tests/codegen/sanitizer/cfi-emit-type-metadata-itanium-cxx-abi-normalized-generalized.rs similarity index 100% rename from tests/codegen/sanitizer-cfi-emit-type-metadata-itanium-cxx-abi-normalized-generalized.rs rename to tests/codegen/sanitizer/cfi-emit-type-metadata-itanium-cxx-abi-normalized-generalized.rs diff --git a/tests/codegen/sanitizer-cfi-emit-type-metadata-itanium-cxx-abi-normalized.rs b/tests/codegen/sanitizer/cfi-emit-type-metadata-itanium-cxx-abi-normalized.rs similarity index 100% rename from tests/codegen/sanitizer-cfi-emit-type-metadata-itanium-cxx-abi-normalized.rs rename to tests/codegen/sanitizer/cfi-emit-type-metadata-itanium-cxx-abi-normalized.rs diff --git a/tests/codegen/sanitizer-cfi-emit-type-metadata-itanium-cxx-abi.rs b/tests/codegen/sanitizer/cfi-emit-type-metadata-itanium-cxx-abi.rs similarity index 100% rename from tests/codegen/sanitizer-cfi-emit-type-metadata-itanium-cxx-abi.rs rename to tests/codegen/sanitizer/cfi-emit-type-metadata-itanium-cxx-abi.rs diff --git a/tests/codegen/sanitizer-cfi-emit-type-metadata-trait-objects.rs b/tests/codegen/sanitizer/cfi-emit-type-metadata-trait-objects.rs similarity index 100% rename from tests/codegen/sanitizer-cfi-emit-type-metadata-trait-objects.rs rename to tests/codegen/sanitizer/cfi-emit-type-metadata-trait-objects.rs diff --git a/tests/codegen/sanitizer-cfi-generalize-pointers.rs b/tests/codegen/sanitizer/cfi-generalize-pointers.rs similarity index 100% rename from tests/codegen/sanitizer-cfi-generalize-pointers.rs rename to tests/codegen/sanitizer/cfi-generalize-pointers.rs diff --git a/tests/codegen/sanitizer-cfi-normalize-integers.rs b/tests/codegen/sanitizer/cfi-normalize-integers.rs similarity index 100% rename from tests/codegen/sanitizer-cfi-normalize-integers.rs rename to tests/codegen/sanitizer/cfi-normalize-integers.rs diff --git a/tests/codegen/sanitizer-kasan-emits-instrumentation.rs b/tests/codegen/sanitizer/kasan-emits-instrumentation.rs similarity index 100% rename from tests/codegen/sanitizer-kasan-emits-instrumentation.rs rename to tests/codegen/sanitizer/kasan-emits-instrumentation.rs diff --git a/tests/codegen/sanitizer-kcfi-add-kcfi-flag.rs b/tests/codegen/sanitizer/kcfi-add-kcfi-flag.rs similarity index 100% rename from tests/codegen/sanitizer-kcfi-add-kcfi-flag.rs rename to tests/codegen/sanitizer/kcfi-add-kcfi-flag.rs diff --git a/tests/codegen/sanitizer-kcfi-emit-kcfi-operand-bundle-attr-no-sanitize.rs b/tests/codegen/sanitizer/kcfi-emit-kcfi-operand-bundle-attr-no-sanitize.rs similarity index 100% rename from tests/codegen/sanitizer-kcfi-emit-kcfi-operand-bundle-attr-no-sanitize.rs rename to tests/codegen/sanitizer/kcfi-emit-kcfi-operand-bundle-attr-no-sanitize.rs diff --git a/tests/codegen/sanitizer-kcfi-emit-kcfi-operand-bundle-itanium-cxx-abi-generalized.rs b/tests/codegen/sanitizer/kcfi-emit-kcfi-operand-bundle-itanium-cxx-abi-generalized.rs similarity index 100% rename from tests/codegen/sanitizer-kcfi-emit-kcfi-operand-bundle-itanium-cxx-abi-generalized.rs rename to tests/codegen/sanitizer/kcfi-emit-kcfi-operand-bundle-itanium-cxx-abi-generalized.rs diff --git a/tests/codegen/sanitizer-kcfi-emit-kcfi-operand-bundle-itanium-cxx-abi-normalized-generalized.rs b/tests/codegen/sanitizer/kcfi-emit-kcfi-operand-bundle-itanium-cxx-abi-normalized-generalized.rs similarity index 100% rename from tests/codegen/sanitizer-kcfi-emit-kcfi-operand-bundle-itanium-cxx-abi-normalized-generalized.rs rename to tests/codegen/sanitizer/kcfi-emit-kcfi-operand-bundle-itanium-cxx-abi-normalized-generalized.rs diff --git a/tests/codegen/sanitizer-kcfi-emit-kcfi-operand-bundle-itanium-cxx-abi-normalized.rs b/tests/codegen/sanitizer/kcfi-emit-kcfi-operand-bundle-itanium-cxx-abi-normalized.rs similarity index 100% rename from tests/codegen/sanitizer-kcfi-emit-kcfi-operand-bundle-itanium-cxx-abi-normalized.rs rename to tests/codegen/sanitizer/kcfi-emit-kcfi-operand-bundle-itanium-cxx-abi-normalized.rs diff --git a/tests/codegen/sanitizer-kcfi-emit-kcfi-operand-bundle-itanium-cxx-abi.rs b/tests/codegen/sanitizer/kcfi-emit-kcfi-operand-bundle-itanium-cxx-abi.rs similarity index 100% rename from tests/codegen/sanitizer-kcfi-emit-kcfi-operand-bundle-itanium-cxx-abi.rs rename to tests/codegen/sanitizer/kcfi-emit-kcfi-operand-bundle-itanium-cxx-abi.rs diff --git a/tests/codegen/sanitizer-kcfi-emit-kcfi-operand-bundle.rs b/tests/codegen/sanitizer/kcfi-emit-kcfi-operand-bundle.rs similarity index 100% rename from tests/codegen/sanitizer-kcfi-emit-kcfi-operand-bundle.rs rename to tests/codegen/sanitizer/kcfi-emit-kcfi-operand-bundle.rs diff --git a/tests/codegen/sanitizer-kcfi-emit-type-metadata-trait-objects.rs b/tests/codegen/sanitizer/kcfi-emit-type-metadata-trait-objects.rs similarity index 100% rename from tests/codegen/sanitizer-kcfi-emit-type-metadata-trait-objects.rs rename to tests/codegen/sanitizer/kcfi-emit-type-metadata-trait-objects.rs diff --git a/tests/codegen/sanitizer-memory-track-orgins.rs b/tests/codegen/sanitizer/memory-track-origins.rs similarity index 100% rename from tests/codegen/sanitizer-memory-track-orgins.rs rename to tests/codegen/sanitizer/memory-track-origins.rs diff --git a/tests/codegen/sanitizer_memtag_attr_check.rs b/tests/codegen/sanitizer/memtag-attr-check.rs similarity index 100% rename from tests/codegen/sanitizer_memtag_attr_check.rs rename to tests/codegen/sanitizer/memtag-attr-check.rs diff --git a/tests/codegen/sanitizer-no-sanitize-inlining.rs b/tests/codegen/sanitizer/no-sanitize-inlining.rs similarity index 100% rename from tests/codegen/sanitizer-no-sanitize-inlining.rs rename to tests/codegen/sanitizer/no-sanitize-inlining.rs diff --git a/tests/codegen/sanitizer-no-sanitize.rs b/tests/codegen/sanitizer/no-sanitize.rs similarity index 100% rename from tests/codegen/sanitizer-no-sanitize.rs rename to tests/codegen/sanitizer/no-sanitize.rs diff --git a/tests/codegen/sanitizer-safestack-attr-check.rs b/tests/codegen/sanitizer/safestack-attr-check.rs similarity index 100% rename from tests/codegen/sanitizer-safestack-attr-check.rs rename to tests/codegen/sanitizer/safestack-attr-check.rs diff --git a/tests/codegen/sanitizer-recover.rs b/tests/codegen/sanitizer/sanitizer-recover.rs similarity index 100% rename from tests/codegen/sanitizer-recover.rs rename to tests/codegen/sanitizer/sanitizer-recover.rs diff --git a/tests/codegen/sanitizer_scs_attr_check.rs b/tests/codegen/sanitizer/scs-attr-check.rs similarity index 100% rename from tests/codegen/sanitizer_scs_attr_check.rs rename to tests/codegen/sanitizer/scs-attr-check.rs From 4d2957cfdf83f7ace6421caf8ceae28236af4366 Mon Sep 17 00:00:00 2001 From: Jubilee Young Date: Sat, 29 Jul 2023 18:04:26 -0700 Subject: [PATCH 03/18] Fix sanitizer tests depending on filename In the basic case, simply do the string substitution. For one case with many instances, capture the Itanium- mangled filename and assert its reuse instead. --- .../cfi-emit-type-checks-attr-no-sanitize.rs | 2 +- ...i-emit-type-metadata-id-itanium-cxx-abi.rs | 96 +++++++++---------- .../sanitizer/kasan-emits-instrumentation.rs | 4 +- ...it-kcfi-operand-bundle-attr-no-sanitize.rs | 2 +- tests/codegen/sanitizer/no-sanitize.rs | 4 +- 5 files changed, 54 insertions(+), 54 deletions(-) diff --git a/tests/codegen/sanitizer/cfi-emit-type-checks-attr-no-sanitize.rs b/tests/codegen/sanitizer/cfi-emit-type-checks-attr-no-sanitize.rs index 2b61c9078fd9c..a3cd16e3dd5a5 100644 --- a/tests/codegen/sanitizer/cfi-emit-type-checks-attr-no-sanitize.rs +++ b/tests/codegen/sanitizer/cfi-emit-type-checks-attr-no-sanitize.rs @@ -8,7 +8,7 @@ #[no_sanitize(cfi)] pub fn foo(f: fn(i32) -> i32, arg: i32) -> i32 { - // CHECK-LABEL: sanitizer_cfi_emit_type_checks_attr_no_sanitize::foo + // CHECK-LABEL: cfi_emit_type_checks_attr_no_sanitize::foo // CHECK: Function Attrs: {{.*}} // CHECK-LABEL: define{{.*}}foo{{.*}}!type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} // CHECK: start: diff --git a/tests/codegen/sanitizer/cfi-emit-type-metadata-id-itanium-cxx-abi.rs b/tests/codegen/sanitizer/cfi-emit-type-metadata-id-itanium-cxx-abi.rs index 63e63c5d4aa92..da608e180c536 100644 --- a/tests/codegen/sanitizer/cfi-emit-type-metadata-id-itanium-cxx-abi.rs +++ b/tests/codegen/sanitizer/cfi-emit-type-metadata-id-itanium-cxx-abi.rs @@ -521,15 +521,15 @@ pub fn foo149(_: Type14, _: Type14, _: Type14) { } // CHECK: ![[TYPE66]] = !{i64 0, !"_ZTSFvu3refIu5sliceIu3i32EEE"} // CHECK: ![[TYPE67]] = !{i64 0, !"_ZTSFvu3refIu5sliceIu3i32EES1_E"} // CHECK: ![[TYPE68]] = !{i64 0, !"_ZTSFvu3refIu5sliceIu3i32EES1_S1_E"} -// CHECK: ![[TYPE69]] = !{i64 0, !"_ZTSFvu3refIu{{[0-9]+}}NtC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi7Struct1Iu3i32EEE"} -// CHECK: ![[TYPE70]] = !{i64 0, !"_ZTSFvu3refIu{{[0-9]+}}NtC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi7Struct1Iu3i32EES1_E"} -// CHECK: ![[TYPE71]] = !{i64 0, !"_ZTSFvu3refIu{{[0-9]+}}NtC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi7Struct1Iu3i32EES1_S1_E"} -// CHECK: ![[TYPE72]] = !{i64 0, !"_ZTSFvu3refIu{{[0-9]+}}NtC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi5Enum1Iu3i32EEE"} -// CHECK: ![[TYPE73]] = !{i64 0, !"_ZTSFvu3refIu{{[0-9]+}}NtC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi5Enum1Iu3i32EES1_E"} -// CHECK: ![[TYPE74]] = !{i64 0, !"_ZTSFvu3refIu{{[0-9]+}}NtC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi5Enum1Iu3i32EES1_S1_E"} -// CHECK: ![[TYPE75]] = !{i64 0, !"_ZTSFvu3refIu{{[0-9]+}}NtC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi6Union1Iu3i32EEE"} -// CHECK: ![[TYPE76]] = !{i64 0, !"_ZTSFvu3refIu{{[0-9]+}}NtC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi6Union1Iu3i32EES1_E"} -// CHECK: ![[TYPE77]] = !{i64 0, !"_ZTSFvu3refIu{{[0-9]+}}NtC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi6Union1Iu3i32EES1_S1_E"} +// CHECK: ![[TYPE69]] = !{i64 0, !"_ZTSFvu3refIu{{[0-9]+}}NtC{{[[:print:]]+}}_[[ITANIUMED_FILENAME:[0-9]{1,2}[a-z_]{1,99}]]7Struct1Iu3i32EEE"} +// CHECK: ![[TYPE70]] = !{i64 0, !"_ZTSFvu3refIu{{[0-9]+}}NtC{{[[:print:]]+}}_[[ITANIUMED_FILENAME]]7Struct1Iu3i32EES1_E"} +// CHECK: ![[TYPE71]] = !{i64 0, !"_ZTSFvu3refIu{{[0-9]+}}NtC{{[[:print:]]+}}_[[ITANIUMED_FILENAME]]7Struct1Iu3i32EES1_S1_E"} +// CHECK: ![[TYPE72]] = !{i64 0, !"_ZTSFvu3refIu{{[0-9]+}}NtC{{[[:print:]]+}}_[[ITANIUMED_FILENAME]]5Enum1Iu3i32EEE"} +// CHECK: ![[TYPE73]] = !{i64 0, !"_ZTSFvu3refIu{{[0-9]+}}NtC{{[[:print:]]+}}_[[ITANIUMED_FILENAME]]5Enum1Iu3i32EES1_E"} +// CHECK: ![[TYPE74]] = !{i64 0, !"_ZTSFvu3refIu{{[0-9]+}}NtC{{[[:print:]]+}}_[[ITANIUMED_FILENAME]]5Enum1Iu3i32EES1_S1_E"} +// CHECK: ![[TYPE75]] = !{i64 0, !"_ZTSFvu3refIu{{[0-9]+}}NtC{{[[:print:]]+}}_[[ITANIUMED_FILENAME]]6Union1Iu3i32EEE"} +// CHECK: ![[TYPE76]] = !{i64 0, !"_ZTSFvu3refIu{{[0-9]+}}NtC{{[[:print:]]+}}_[[ITANIUMED_FILENAME]]6Union1Iu3i32EES1_E"} +// CHECK: ![[TYPE77]] = !{i64 0, !"_ZTSFvu3refIu{{[0-9]+}}NtC{{[[:print:]]+}}_[[ITANIUMED_FILENAME]]6Union1Iu3i32EES1_S1_E"} // CHECK: ![[TYPE78]] = !{i64 0, !"_ZTSFvP5type1E"} // CHECK: ![[TYPE79]] = !{i64 0, !"_ZTSFvP5type1S0_E"} // CHECK: ![[TYPE80]] = !{i64 0, !"_ZTSFvP5type1S0_S0_E"} @@ -560,45 +560,45 @@ pub fn foo149(_: Type14, _: Type14, _: Type14) { } // CHECK: ![[TYPE105]] = !{i64 0, !"_ZTSFvu3refIu3dynIu{{[0-9]+}}NtNtC{{[[:print:]]+}}_4core6marker4Sendu6regionEEE"} // CHECK: ![[TYPE106]] = !{i64 0, !"_ZTSFvu3refIu3dynIu{{[0-9]+}}NtNtC{{[[:print:]]+}}_4core6marker4Sendu6regionEES2_E"} // CHECK: ![[TYPE107]] = !{i64 0, !"_ZTSFvu3refIu3dynIu{{[0-9]+}}NtNtC{{[[:print:]]+}}_4core6marker4Sendu6regionEES2_S2_E"} -// CHECK: ![[TYPE108]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NCNvC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi3fn111{{[{}][{}]}}closure{{[}][}]}}Iu2i8PFvvEvEE"} -// CHECK: ![[TYPE109]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NCNvC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi3fn111{{[{}][{}]}}closure{{[}][}]}}Iu2i8PFvvEvES1_E"} -// CHECK: ![[TYPE110]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NCNvC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi3fn111{{[{}][{}]}}closure{{[}][}]}}Iu2i8PFvvEvES1_S1_E"} -// CHECK: ![[TYPE111]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NcNtNvC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi3fn13Foo15{{[{}][{}]}}constructor{{[}][}]}}E"} -// CHECK: ![[TYPE112]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NcNtNvC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi3fn13Foo15{{[{}][{}]}}constructor{{[}][}]}}S_E"} -// CHECK: ![[TYPE113]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NcNtNvC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi3fn13Foo15{{[{}][{}]}}constructor{{[}][}]}}S_S_E"} -// CHECK: ![[TYPE114]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NvNFNvC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi3fn110{{[{}][{}]}}extern{{[}][}]}}3fooE"} -// CHECK: ![[TYPE115]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NvNFNvC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi3fn110{{[{}][{}]}}extern{{[}][}]}}3fooS_E"} -// CHECK: ![[TYPE116]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NvNFNvC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi3fn110{{[{}][{}]}}extern{{[}][}]}}3fooS_S_E"} -// CHECK: ![[TYPE117]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NtNCNvC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi3fn1s0_11{{[{}][{}]}}closure{{[}][}]}}3FooE"} -// CHECK: ![[TYPE118]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NtNCNvC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi3fn1s0_11{{[{}][{}]}}closure{{[}][}]}}3FooS_E"} -// CHECK: ![[TYPE119]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NtNCNvC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi3fn1s0_11{{[{}][{}]}}closure{{[}][}]}}3FooS_S_E"} -// CHECK: ![[TYPE120]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NtNkNvC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi3fn112{{[{}][{}]}}constant{{[}][}]}}3FooE"} -// CHECK: ![[TYPE121]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NtNkNvC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi3fn112{{[{}][{}]}}constant{{[}][}]}}3FooS_E"} -// CHECK: ![[TYPE122]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NtNkNvC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi3fn112{{[{}][{}]}}constant{{[}][}]}}3FooS_S_E"} -// CHECK: ![[TYPE123]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NvNINvC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi3fn18{{[{}][{}]}}impl{{[}][}]}}3fooIu3i32EE"} -// CHECK: ![[TYPE124]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NvNINvC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi3fn18{{[{}][{}]}}impl{{[}][}]}}3fooIu3i32ES0_E"} -// CHECK: ![[TYPE125]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NvNINvC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi3fn18{{[{}][{}]}}impl{{[}][}]}}3fooIu3i32ES0_S0_E"} -// CHECK: ![[TYPE126]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NvNtC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi6Trait13fooIu3dynIu{{[0-9]+}}NtC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi6Trait1Iu5paramEu6regionEu3i32EE"} -// CHECK: ![[TYPE127]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NvNtC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi6Trait13fooIu3dynIu{{[0-9]+}}NtC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi6Trait1Iu5paramEu6regionEu3i32ES4_E"} -// CHECK: ![[TYPE128]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NvNtC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi6Trait13fooIu3dynIu{{[0-9]+}}NtC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi6Trait1Iu5paramEu6regionEu3i32ES4_S4_E"} -// CHECK: ![[TYPE129]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NvNtC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi6Trait13fooIu3i32S_EE"} -// CHECK: ![[TYPE130]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NvNtC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi6Trait13fooIu3i32S_ES0_E"} -// CHECK: ![[TYPE131]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NvNtC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi6Trait13fooIu3i32S_ES0_S0_E"} -// CHECK: ![[TYPE132]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NvNtC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi6Trait13fooIu{{[0-9]+}}NtC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi7Struct1Iu3i32ES_EE"} -// CHECK: ![[TYPE133]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NvNtC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi6Trait13fooIu{{[0-9]+}}NtC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi7Struct1Iu3i32ES_ES1_E"} -// CHECK: ![[TYPE134]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NvNtC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi6Trait13fooIu{{[0-9]+}}NtC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi7Struct1Iu3i32ES_ES1_S1_E"} -// CHECK: ![[TYPE135]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NtNvC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi3fn13QuxIu3i32Lu5usize32EEE"} -// CHECK: ![[TYPE136]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NtNvC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi3fn13QuxIu3i32Lu5usize32EES2_E"} -// CHECK: ![[TYPE137]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NtNvC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi3fn13QuxIu3i32Lu5usize32EES2_S2_E"} -// CHECK: ![[TYPE138]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NcNtNvC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi3fn15Quuux15{{[{}][{}]}}constructor{{[}][}]}}Iu6regionS_EE"} -// CHECK: ![[TYPE139]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NcNtNvC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi3fn15Quuux15{{[{}][{}]}}constructor{{[}][}]}}Iu6regionS_ES0_E"} -// CHECK: ![[TYPE140]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NcNtNvC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi3fn15Quuux15{{[{}][{}]}}constructor{{[}][}]}}Iu6regionS_ES0_S0_E"} -// CHECK: ![[TYPE141]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NtC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi3FooE"} -// CHECK: ![[TYPE142]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NtC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi3FooS_E"} -// CHECK: ![[TYPE143]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NtC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi3FooS_S_E"} +// CHECK: ![[TYPE108]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NCNvC{{[[:print:]]+}}_[[ITANIUMED_FILENAME]]3fn111{{[{}][{}]}}closure{{[}][}]}}Iu2i8PFvvEvEE"} +// CHECK: ![[TYPE109]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NCNvC{{[[:print:]]+}}_[[ITANIUMED_FILENAME]]3fn111{{[{}][{}]}}closure{{[}][}]}}Iu2i8PFvvEvES1_E"} +// CHECK: ![[TYPE110]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NCNvC{{[[:print:]]+}}_[[ITANIUMED_FILENAME]]3fn111{{[{}][{}]}}closure{{[}][}]}}Iu2i8PFvvEvES1_S1_E"} +// CHECK: ![[TYPE111]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NcNtNvC{{[[:print:]]+}}_[[ITANIUMED_FILENAME]]3fn13Foo15{{[{}][{}]}}constructor{{[}][}]}}E"} +// CHECK: ![[TYPE112]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NcNtNvC{{[[:print:]]+}}_[[ITANIUMED_FILENAME]]3fn13Foo15{{[{}][{}]}}constructor{{[}][}]}}S_E"} +// CHECK: ![[TYPE113]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NcNtNvC{{[[:print:]]+}}_[[ITANIUMED_FILENAME]]3fn13Foo15{{[{}][{}]}}constructor{{[}][}]}}S_S_E"} +// CHECK: ![[TYPE114]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NvNFNvC{{[[:print:]]+}}_[[ITANIUMED_FILENAME]]3fn110{{[{}][{}]}}extern{{[}][}]}}3fooE"} +// CHECK: ![[TYPE115]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NvNFNvC{{[[:print:]]+}}_[[ITANIUMED_FILENAME]]3fn110{{[{}][{}]}}extern{{[}][}]}}3fooS_E"} +// CHECK: ![[TYPE116]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NvNFNvC{{[[:print:]]+}}_[[ITANIUMED_FILENAME]]3fn110{{[{}][{}]}}extern{{[}][}]}}3fooS_S_E"} +// CHECK: ![[TYPE117]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NtNCNvC{{[[:print:]]+}}_[[ITANIUMED_FILENAME]]3fn1s0_11{{[{}][{}]}}closure{{[}][}]}}3FooE"} +// CHECK: ![[TYPE118]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NtNCNvC{{[[:print:]]+}}_[[ITANIUMED_FILENAME]]3fn1s0_11{{[{}][{}]}}closure{{[}][}]}}3FooS_E"} +// CHECK: ![[TYPE119]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NtNCNvC{{[[:print:]]+}}_[[ITANIUMED_FILENAME]]3fn1s0_11{{[{}][{}]}}closure{{[}][}]}}3FooS_S_E"} +// CHECK: ![[TYPE120]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NtNkNvC{{[[:print:]]+}}_[[ITANIUMED_FILENAME]]3fn112{{[{}][{}]}}constant{{[}][}]}}3FooE"} +// CHECK: ![[TYPE121]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NtNkNvC{{[[:print:]]+}}_[[ITANIUMED_FILENAME]]3fn112{{[{}][{}]}}constant{{[}][}]}}3FooS_E"} +// CHECK: ![[TYPE122]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NtNkNvC{{[[:print:]]+}}_[[ITANIUMED_FILENAME]]3fn112{{[{}][{}]}}constant{{[}][}]}}3FooS_S_E"} +// CHECK: ![[TYPE123]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NvNINvC{{[[:print:]]+}}_[[ITANIUMED_FILENAME]]3fn18{{[{}][{}]}}impl{{[}][}]}}3fooIu3i32EE"} +// CHECK: ![[TYPE124]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NvNINvC{{[[:print:]]+}}_[[ITANIUMED_FILENAME]]3fn18{{[{}][{}]}}impl{{[}][}]}}3fooIu3i32ES0_E"} +// CHECK: ![[TYPE125]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NvNINvC{{[[:print:]]+}}_[[ITANIUMED_FILENAME]]3fn18{{[{}][{}]}}impl{{[}][}]}}3fooIu3i32ES0_S0_E"} +// CHECK: ![[TYPE126]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NvNtC{{[[:print:]]+}}_[[ITANIUMED_FILENAME]]6Trait13fooIu3dynIu{{[0-9]+}}NtC{{[[:print:]]+}}_[[ITANIUMED_FILENAME]]6Trait1Iu5paramEu6regionEu3i32EE"} +// CHECK: ![[TYPE127]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NvNtC{{[[:print:]]+}}_[[ITANIUMED_FILENAME]]6Trait13fooIu3dynIu{{[0-9]+}}NtC{{[[:print:]]+}}_[[ITANIUMED_FILENAME]]6Trait1Iu5paramEu6regionEu3i32ES4_E"} +// CHECK: ![[TYPE128]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NvNtC{{[[:print:]]+}}_[[ITANIUMED_FILENAME]]6Trait13fooIu3dynIu{{[0-9]+}}NtC{{[[:print:]]+}}_[[ITANIUMED_FILENAME]]6Trait1Iu5paramEu6regionEu3i32ES4_S4_E"} +// CHECK: ![[TYPE129]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NvNtC{{[[:print:]]+}}_[[ITANIUMED_FILENAME]]6Trait13fooIu3i32S_EE"} +// CHECK: ![[TYPE130]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NvNtC{{[[:print:]]+}}_[[ITANIUMED_FILENAME]]6Trait13fooIu3i32S_ES0_E"} +// CHECK: ![[TYPE131]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NvNtC{{[[:print:]]+}}_[[ITANIUMED_FILENAME]]6Trait13fooIu3i32S_ES0_S0_E"} +// CHECK: ![[TYPE132]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NvNtC{{[[:print:]]+}}_[[ITANIUMED_FILENAME]]6Trait13fooIu{{[0-9]+}}NtC{{[[:print:]]+}}_[[ITANIUMED_FILENAME]]7Struct1Iu3i32ES_EE"} +// CHECK: ![[TYPE133]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NvNtC{{[[:print:]]+}}_[[ITANIUMED_FILENAME]]6Trait13fooIu{{[0-9]+}}NtC{{[[:print:]]+}}_[[ITANIUMED_FILENAME]]7Struct1Iu3i32ES_ES1_E"} +// CHECK: ![[TYPE134]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NvNtC{{[[:print:]]+}}_[[ITANIUMED_FILENAME]]6Trait13fooIu{{[0-9]+}}NtC{{[[:print:]]+}}_[[ITANIUMED_FILENAME]]7Struct1Iu3i32ES_ES1_S1_E"} +// CHECK: ![[TYPE135]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NtNvC{{[[:print:]]+}}_[[ITANIUMED_FILENAME]]3fn13QuxIu3i32Lu5usize32EEE"} +// CHECK: ![[TYPE136]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NtNvC{{[[:print:]]+}}_[[ITANIUMED_FILENAME]]3fn13QuxIu3i32Lu5usize32EES2_E"} +// CHECK: ![[TYPE137]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NtNvC{{[[:print:]]+}}_[[ITANIUMED_FILENAME]]3fn13QuxIu3i32Lu5usize32EES2_S2_E"} +// CHECK: ![[TYPE138]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NcNtNvC{{[[:print:]]+}}_[[ITANIUMED_FILENAME]]3fn15Quuux15{{[{}][{}]}}constructor{{[}][}]}}Iu6regionS_EE"} +// CHECK: ![[TYPE139]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NcNtNvC{{[[:print:]]+}}_[[ITANIUMED_FILENAME]]3fn15Quuux15{{[{}][{}]}}constructor{{[}][}]}}Iu6regionS_ES0_E"} +// CHECK: ![[TYPE140]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NcNtNvC{{[[:print:]]+}}_[[ITANIUMED_FILENAME]]3fn15Quuux15{{[{}][{}]}}constructor{{[}][}]}}Iu6regionS_ES0_S0_E"} +// CHECK: ![[TYPE141]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NtC{{[[:print:]]+}}_[[ITANIUMED_FILENAME]]3FooE"} +// CHECK: ![[TYPE142]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NtC{{[[:print:]]+}}_[[ITANIUMED_FILENAME]]3FooS_E"} +// CHECK: ![[TYPE143]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NtC{{[[:print:]]+}}_[[ITANIUMED_FILENAME]]3FooS_S_E"} // CHECK: ![[TYPE144]] = !{i64 0, !"_ZTSFvu3refIvEE"} // CHECK: ![[TYPE145]] = !{i64 0, !"_ZTSFvu3refIvES_E"} // CHECK: ![[TYPE146]] = !{i64 0, !"_ZTSFvu3refIvES_S_E"} -// CHECK: ![[TYPE147]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NtC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi3BarE"} -// CHECK: ![[TYPE148]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NtC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi3BarS_E"} -// CHECK: ![[TYPE149]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NtC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi3BarS_S_E"} +// CHECK: ![[TYPE147]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NtC{{[[:print:]]+}}_[[ITANIUMED_FILENAME]]3BarE"} +// CHECK: ![[TYPE148]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NtC{{[[:print:]]+}}_[[ITANIUMED_FILENAME]]3BarS_E"} +// CHECK: ![[TYPE149]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NtC{{[[:print:]]+}}_[[ITANIUMED_FILENAME]]3BarS_S_E"} diff --git a/tests/codegen/sanitizer/kasan-emits-instrumentation.rs b/tests/codegen/sanitizer/kasan-emits-instrumentation.rs index d6e3f2719df70..783bc47b9d059 100644 --- a/tests/codegen/sanitizer/kasan-emits-instrumentation.rs +++ b/tests/codegen/sanitizer/kasan-emits-instrumentation.rs @@ -25,7 +25,7 @@ trait Copy {} impl Copy for u8 {} -// CHECK-LABEL: ; sanitizer_kasan_emits_instrumentation::unsanitized +// CHECK-LABEL: ; kasan_emits_instrumentation::unsanitized // CHECK-NEXT: ; Function Attrs: // CHECK-NOT: sanitize_address // CHECK: start: @@ -36,7 +36,7 @@ pub fn unsanitized(b: &mut u8) -> u8 { *b } -// CHECK-LABEL: ; sanitizer_kasan_emits_instrumentation::sanitized +// CHECK-LABEL: ; kasan_emits_instrumentation::sanitized // CHECK-NEXT: ; Function Attrs: // CHECK: sanitize_address // CHECK: start: diff --git a/tests/codegen/sanitizer/kcfi-emit-kcfi-operand-bundle-attr-no-sanitize.rs b/tests/codegen/sanitizer/kcfi-emit-kcfi-operand-bundle-attr-no-sanitize.rs index bb317e4a2fad3..001fc956aaaf9 100644 --- a/tests/codegen/sanitizer/kcfi-emit-kcfi-operand-bundle-attr-no-sanitize.rs +++ b/tests/codegen/sanitizer/kcfi-emit-kcfi-operand-bundle-attr-no-sanitize.rs @@ -20,7 +20,7 @@ impl Copy for i32 {} #[no_sanitize(kcfi)] pub fn foo(f: fn(i32) -> i32, arg: i32) -> i32 { - // CHECK-LABEL: sanitizer_kcfi_emit_kcfi_operand_bundle_attr_no_sanitize::foo + // CHECK-LABEL: kcfi_emit_kcfi_operand_bundle_attr_no_sanitize::foo // CHECK: Function Attrs: {{.*}} // CHECK-LABEL: define{{.*}}foo{{.*}}!{{|kcfi_type}} !{{[0-9]+}} // CHECK: start: diff --git a/tests/codegen/sanitizer/no-sanitize.rs b/tests/codegen/sanitizer/no-sanitize.rs index fb9d249da03d5..783b568e2792f 100644 --- a/tests/codegen/sanitizer/no-sanitize.rs +++ b/tests/codegen/sanitizer/no-sanitize.rs @@ -7,7 +7,7 @@ #![crate_type="lib"] #![feature(no_sanitize)] -// CHECK-LABEL: ; sanitizer_no_sanitize::unsanitized +// CHECK-LABEL: ; no_sanitize::unsanitized // CHECK-NEXT: ; Function Attrs: // CHECK-NOT: sanitize_address // CHECK: start: @@ -18,7 +18,7 @@ pub fn unsanitized(b: &mut u8) -> u8 { *b } -// CHECK-LABEL: ; sanitizer_no_sanitize::sanitized +// CHECK-LABEL: ; no_sanitize::sanitized // CHECK-NEXT: ; Function Attrs: // CHECK: sanitize_address // CHECK: start: From 06711615aa5b3d45e77c1aa20df7de14ed16edf2 Mon Sep 17 00:00:00 2001 From: Jubilee Young Date: Sat, 29 Jul 2023 17:07:57 -0700 Subject: [PATCH 04/18] tests/codegen/enum-* -> enum/enum-* --- tests/codegen/{ => enum}/enum-bounds-check-derived-idx.rs | 0 tests/codegen/{ => enum}/enum-bounds-check-issue-13926.rs | 0 tests/codegen/{ => enum}/enum-bounds-check-issue-82871.rs | 0 tests/codegen/{ => enum}/enum-bounds-check.rs | 0 tests/codegen/{ => enum}/enum-debug-clike.rs | 0 tests/codegen/{ => enum}/enum-debug-niche-2.rs | 0 tests/codegen/{ => enum}/enum-debug-niche.rs | 0 tests/codegen/{ => enum}/enum-debug-tagged.rs | 0 tests/codegen/{ => enum}/enum-discriminant-value.rs | 0 tests/codegen/{ => enum}/enum-match.rs | 0 tests/codegen/{ => enum}/enum-u128.rs | 0 11 files changed, 0 insertions(+), 0 deletions(-) rename tests/codegen/{ => enum}/enum-bounds-check-derived-idx.rs (100%) rename tests/codegen/{ => enum}/enum-bounds-check-issue-13926.rs (100%) rename tests/codegen/{ => enum}/enum-bounds-check-issue-82871.rs (100%) rename tests/codegen/{ => enum}/enum-bounds-check.rs (100%) rename tests/codegen/{ => enum}/enum-debug-clike.rs (100%) rename tests/codegen/{ => enum}/enum-debug-niche-2.rs (100%) rename tests/codegen/{ => enum}/enum-debug-niche.rs (100%) rename tests/codegen/{ => enum}/enum-debug-tagged.rs (100%) rename tests/codegen/{ => enum}/enum-discriminant-value.rs (100%) rename tests/codegen/{ => enum}/enum-match.rs (100%) rename tests/codegen/{ => enum}/enum-u128.rs (100%) diff --git a/tests/codegen/enum-bounds-check-derived-idx.rs b/tests/codegen/enum/enum-bounds-check-derived-idx.rs similarity index 100% rename from tests/codegen/enum-bounds-check-derived-idx.rs rename to tests/codegen/enum/enum-bounds-check-derived-idx.rs diff --git a/tests/codegen/enum-bounds-check-issue-13926.rs b/tests/codegen/enum/enum-bounds-check-issue-13926.rs similarity index 100% rename from tests/codegen/enum-bounds-check-issue-13926.rs rename to tests/codegen/enum/enum-bounds-check-issue-13926.rs diff --git a/tests/codegen/enum-bounds-check-issue-82871.rs b/tests/codegen/enum/enum-bounds-check-issue-82871.rs similarity index 100% rename from tests/codegen/enum-bounds-check-issue-82871.rs rename to tests/codegen/enum/enum-bounds-check-issue-82871.rs diff --git a/tests/codegen/enum-bounds-check.rs b/tests/codegen/enum/enum-bounds-check.rs similarity index 100% rename from tests/codegen/enum-bounds-check.rs rename to tests/codegen/enum/enum-bounds-check.rs diff --git a/tests/codegen/enum-debug-clike.rs b/tests/codegen/enum/enum-debug-clike.rs similarity index 100% rename from tests/codegen/enum-debug-clike.rs rename to tests/codegen/enum/enum-debug-clike.rs diff --git a/tests/codegen/enum-debug-niche-2.rs b/tests/codegen/enum/enum-debug-niche-2.rs similarity index 100% rename from tests/codegen/enum-debug-niche-2.rs rename to tests/codegen/enum/enum-debug-niche-2.rs diff --git a/tests/codegen/enum-debug-niche.rs b/tests/codegen/enum/enum-debug-niche.rs similarity index 100% rename from tests/codegen/enum-debug-niche.rs rename to tests/codegen/enum/enum-debug-niche.rs diff --git a/tests/codegen/enum-debug-tagged.rs b/tests/codegen/enum/enum-debug-tagged.rs similarity index 100% rename from tests/codegen/enum-debug-tagged.rs rename to tests/codegen/enum/enum-debug-tagged.rs diff --git a/tests/codegen/enum-discriminant-value.rs b/tests/codegen/enum/enum-discriminant-value.rs similarity index 100% rename from tests/codegen/enum-discriminant-value.rs rename to tests/codegen/enum/enum-discriminant-value.rs diff --git a/tests/codegen/enum-match.rs b/tests/codegen/enum/enum-match.rs similarity index 100% rename from tests/codegen/enum-match.rs rename to tests/codegen/enum/enum-match.rs diff --git a/tests/codegen/enum-u128.rs b/tests/codegen/enum/enum-u128.rs similarity index 100% rename from tests/codegen/enum-u128.rs rename to tests/codegen/enum/enum-u128.rs From df2264a2845089fee6897e17123d2b78a3a189c1 Mon Sep 17 00:00:00 2001 From: Jubilee Young Date: Sat, 29 Jul 2023 17:09:31 -0700 Subject: [PATCH 05/18] tests/codegen/*-macos-* -> macos/* --- tests/codegen/{ => macos}/i686-macosx-deployment-target.rs | 0 tests/codegen/{ => macos}/i686-no-macosx-deployment-target.rs | 0 tests/codegen/{ => macos}/x86_64-macosx-deployment-target.rs | 0 tests/codegen/{ => macos}/x86_64-no-macosx-deployment-target.rs | 0 4 files changed, 0 insertions(+), 0 deletions(-) rename tests/codegen/{ => macos}/i686-macosx-deployment-target.rs (100%) rename tests/codegen/{ => macos}/i686-no-macosx-deployment-target.rs (100%) rename tests/codegen/{ => macos}/x86_64-macosx-deployment-target.rs (100%) rename tests/codegen/{ => macos}/x86_64-no-macosx-deployment-target.rs (100%) diff --git a/tests/codegen/i686-macosx-deployment-target.rs b/tests/codegen/macos/i686-macosx-deployment-target.rs similarity index 100% rename from tests/codegen/i686-macosx-deployment-target.rs rename to tests/codegen/macos/i686-macosx-deployment-target.rs diff --git a/tests/codegen/i686-no-macosx-deployment-target.rs b/tests/codegen/macos/i686-no-macosx-deployment-target.rs similarity index 100% rename from tests/codegen/i686-no-macosx-deployment-target.rs rename to tests/codegen/macos/i686-no-macosx-deployment-target.rs diff --git a/tests/codegen/x86_64-macosx-deployment-target.rs b/tests/codegen/macos/x86_64-macosx-deployment-target.rs similarity index 100% rename from tests/codegen/x86_64-macosx-deployment-target.rs rename to tests/codegen/macos/x86_64-macosx-deployment-target.rs diff --git a/tests/codegen/x86_64-no-macosx-deployment-target.rs b/tests/codegen/macos/x86_64-no-macosx-deployment-target.rs similarity index 100% rename from tests/codegen/x86_64-no-macosx-deployment-target.rs rename to tests/codegen/macos/x86_64-no-macosx-deployment-target.rs From 45c284cd98b1b3905e4e54bbc5c40080424425b5 Mon Sep 17 00:00:00 2001 From: Jubilee Young Date: Sat, 29 Jul 2023 17:11:38 -0700 Subject: [PATCH 06/18] tests/codegen/*simd*.rs -> simd/*simd* --- tests/codegen/{ => simd}/simd-wide-sum.rs | 0 tests/codegen/{ => simd}/simd_arith_offset.rs | 0 tests/codegen/{ => simd}/swap-simd-types.rs | 0 tests/codegen/{ => simd}/unpadded-simd.rs | 0 4 files changed, 0 insertions(+), 0 deletions(-) rename tests/codegen/{ => simd}/simd-wide-sum.rs (100%) rename tests/codegen/{ => simd}/simd_arith_offset.rs (100%) rename tests/codegen/{ => simd}/swap-simd-types.rs (100%) rename tests/codegen/{ => simd}/unpadded-simd.rs (100%) diff --git a/tests/codegen/simd-wide-sum.rs b/tests/codegen/simd/simd-wide-sum.rs similarity index 100% rename from tests/codegen/simd-wide-sum.rs rename to tests/codegen/simd/simd-wide-sum.rs diff --git a/tests/codegen/simd_arith_offset.rs b/tests/codegen/simd/simd_arith_offset.rs similarity index 100% rename from tests/codegen/simd_arith_offset.rs rename to tests/codegen/simd/simd_arith_offset.rs diff --git a/tests/codegen/swap-simd-types.rs b/tests/codegen/simd/swap-simd-types.rs similarity index 100% rename from tests/codegen/swap-simd-types.rs rename to tests/codegen/simd/swap-simd-types.rs diff --git a/tests/codegen/unpadded-simd.rs b/tests/codegen/simd/unpadded-simd.rs similarity index 100% rename from tests/codegen/unpadded-simd.rs rename to tests/codegen/simd/unpadded-simd.rs From 0ca0556651f304af3893742ebd6e543648ca1e67 Mon Sep 17 00:00:00 2001 From: Jubilee Young Date: Sat, 29 Jul 2023 17:28:01 -0700 Subject: [PATCH 07/18] tests/codegen/naked-* -> naked-fn/naked-* --- tests/codegen/{ => naked-fn}/naked-functions.rs | 0 tests/codegen/{ => naked-fn}/naked-nocoverage.rs | 0 tests/codegen/{ => naked-fn}/naked-noinline.rs | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename tests/codegen/{ => naked-fn}/naked-functions.rs (100%) rename tests/codegen/{ => naked-fn}/naked-nocoverage.rs (100%) rename tests/codegen/{ => naked-fn}/naked-noinline.rs (100%) diff --git a/tests/codegen/naked-functions.rs b/tests/codegen/naked-fn/naked-functions.rs similarity index 100% rename from tests/codegen/naked-functions.rs rename to tests/codegen/naked-fn/naked-functions.rs diff --git a/tests/codegen/naked-nocoverage.rs b/tests/codegen/naked-fn/naked-nocoverage.rs similarity index 100% rename from tests/codegen/naked-nocoverage.rs rename to tests/codegen/naked-fn/naked-nocoverage.rs diff --git a/tests/codegen/naked-noinline.rs b/tests/codegen/naked-fn/naked-noinline.rs similarity index 100% rename from tests/codegen/naked-noinline.rs rename to tests/codegen/naked-fn/naked-noinline.rs From badba92036e9728a499e118e7a6646fffd33d098 Mon Sep 17 00:00:00 2001 From: Jubilee Young Date: Sat, 29 Jul 2023 17:28:42 -0700 Subject: [PATCH 08/18] tests/codegen/ffi-* -> cffi/ffi-* --- tests/codegen/{ => cffi}/ffi-const.rs | 0 tests/codegen/{ => cffi}/ffi-out-of-bounds-loads.rs | 0 tests/codegen/{ => cffi}/ffi-pure.rs | 0 tests/codegen/{ => cffi}/ffi-returns-twice.rs | 0 4 files changed, 0 insertions(+), 0 deletions(-) rename tests/codegen/{ => cffi}/ffi-const.rs (100%) rename tests/codegen/{ => cffi}/ffi-out-of-bounds-loads.rs (100%) rename tests/codegen/{ => cffi}/ffi-pure.rs (100%) rename tests/codegen/{ => cffi}/ffi-returns-twice.rs (100%) diff --git a/tests/codegen/ffi-const.rs b/tests/codegen/cffi/ffi-const.rs similarity index 100% rename from tests/codegen/ffi-const.rs rename to tests/codegen/cffi/ffi-const.rs diff --git a/tests/codegen/ffi-out-of-bounds-loads.rs b/tests/codegen/cffi/ffi-out-of-bounds-loads.rs similarity index 100% rename from tests/codegen/ffi-out-of-bounds-loads.rs rename to tests/codegen/cffi/ffi-out-of-bounds-loads.rs diff --git a/tests/codegen/ffi-pure.rs b/tests/codegen/cffi/ffi-pure.rs similarity index 100% rename from tests/codegen/ffi-pure.rs rename to tests/codegen/cffi/ffi-pure.rs diff --git a/tests/codegen/ffi-returns-twice.rs b/tests/codegen/cffi/ffi-returns-twice.rs similarity index 100% rename from tests/codegen/ffi-returns-twice.rs rename to tests/codegen/cffi/ffi-returns-twice.rs From f03b31591c65b8fb43537cca83fbd306f24f413d Mon Sep 17 00:00:00 2001 From: Jubilee Young Date: Sat, 29 Jul 2023 17:30:35 -0700 Subject: [PATCH 09/18] tests/codegen/c-variadic* -> cffi/c-variadic* --- tests/codegen/{ => cffi}/c-variadic-copy.rs | 0 tests/codegen/{ => cffi}/c-variadic-opt.rs | 0 tests/codegen/{ => cffi}/c-variadic.rs | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename tests/codegen/{ => cffi}/c-variadic-copy.rs (100%) rename tests/codegen/{ => cffi}/c-variadic-opt.rs (100%) rename tests/codegen/{ => cffi}/c-variadic.rs (100%) diff --git a/tests/codegen/c-variadic-copy.rs b/tests/codegen/cffi/c-variadic-copy.rs similarity index 100% rename from tests/codegen/c-variadic-copy.rs rename to tests/codegen/cffi/c-variadic-copy.rs diff --git a/tests/codegen/c-variadic-opt.rs b/tests/codegen/cffi/c-variadic-opt.rs similarity index 100% rename from tests/codegen/c-variadic-opt.rs rename to tests/codegen/cffi/c-variadic-opt.rs diff --git a/tests/codegen/c-variadic.rs b/tests/codegen/cffi/c-variadic.rs similarity index 100% rename from tests/codegen/c-variadic.rs rename to tests/codegen/cffi/c-variadic.rs From c81d3e23d1aa58571ce82de0af916cc7f3c9a1be Mon Sep 17 00:00:00 2001 From: Jubilee Young Date: Sat, 29 Jul 2023 17:37:09 -0700 Subject: [PATCH 10/18] Remove LLVM 14 codegen tests We raised our LLVM minimum to 15, so these tests seem pointless. --- tests/codegen/box-maybe-uninit-llvm14.rs | 34 ------ tests/codegen/vec-calloc-llvm14.rs | 144 ----------------------- 2 files changed, 178 deletions(-) delete mode 100644 tests/codegen/box-maybe-uninit-llvm14.rs delete mode 100644 tests/codegen/vec-calloc-llvm14.rs diff --git a/tests/codegen/box-maybe-uninit-llvm14.rs b/tests/codegen/box-maybe-uninit-llvm14.rs deleted file mode 100644 index c9f88fb3fe452..0000000000000 --- a/tests/codegen/box-maybe-uninit-llvm14.rs +++ /dev/null @@ -1,34 +0,0 @@ -// compile-flags: -O - -// Once we're done with llvm 14 and earlier, this test can be deleted. - -#![crate_type = "lib"] - -use std::mem::MaybeUninit; - -// Boxing a `MaybeUninit` value should not copy junk from the stack -#[no_mangle] -pub fn box_uninitialized() -> Box> { - // CHECK-LABEL: @box_uninitialized - // CHECK-NOT: store - // CHECK-NOT: alloca - // CHECK-NOT: memcpy - // CHECK-NOT: memset - Box::new(MaybeUninit::uninit()) -} - -// https://github.com/rust-lang/rust/issues/58201 -#[no_mangle] -pub fn box_uninitialized2() -> Box> { - // CHECK-LABEL: @box_uninitialized2 - // CHECK-NOT: store - // CHECK-NOT: alloca - // CHECK-NOT: memcpy - // CHECK-NOT: memset - Box::new(MaybeUninit::uninit()) -} - -// Hide the LLVM 15+ `allocalign` attribute in the declaration of __rust_alloc -// from the CHECK-NOT above. We don't check the attributes here because we can't rely -// on all of them being set until LLVM 15. -// CHECK: declare {{(dso_local )?}}noalias{{.*}} @__rust_alloc(i{{[0-9]+}} noundef, i{{[0-9]+.*}} noundef) diff --git a/tests/codegen/vec-calloc-llvm14.rs b/tests/codegen/vec-calloc-llvm14.rs deleted file mode 100644 index 08302796c41a1..0000000000000 --- a/tests/codegen/vec-calloc-llvm14.rs +++ /dev/null @@ -1,144 +0,0 @@ -// compile-flags: -O -// only-x86_64 -// ignore-debug - -#![crate_type = "lib"] - -// CHECK-LABEL: @vec_zero_bytes -#[no_mangle] -pub fn vec_zero_bytes(n: usize) -> Vec { - // CHECK-NOT: call {{.*}}alloc::vec::from_elem - // CHECK-NOT: call {{.*}}reserve - // CHECK-NOT: call {{.*}}__rust_alloc( - // CHECK-NOT: call {{.*}}llvm.memset - - // CHECK: call {{.*}}__rust_alloc_zeroed( - - // CHECK-NOT: call {{.*}}alloc::vec::from_elem - // CHECK-NOT: call {{.*}}reserve - // CHECK-NOT: call {{.*}}__rust_alloc( - // CHECK-NOT: call {{.*}}llvm.memset - - // CHECK: ret void - vec![0; n] -} - -// CHECK-LABEL: @vec_one_bytes -#[no_mangle] -pub fn vec_one_bytes(n: usize) -> Vec { - // CHECK-NOT: call {{.*}}alloc::vec::from_elem - // CHECK-NOT: call {{.*}}reserve - // CHECK-NOT: call {{.*}}__rust_alloc_zeroed( - - // CHECK: call {{.*}}__rust_alloc( - // CHECK: call {{.*}}llvm.memset - - // CHECK-NOT: call {{.*}}alloc::vec::from_elem - // CHECK-NOT: call {{.*}}reserve - // CHECK-NOT: call {{.*}}__rust_alloc_zeroed( - - // CHECK: ret void - vec![1; n] -} - -// CHECK-LABEL: @vec_zero_scalar -#[no_mangle] -pub fn vec_zero_scalar(n: usize) -> Vec { - // CHECK-NOT: call {{.*}}alloc::vec::from_elem - // CHECK-NOT: call {{.*}}reserve - // CHECK-NOT: call {{.*}}__rust_alloc( - - // CHECK: call {{.*}}__rust_alloc_zeroed( - - // CHECK-NOT: call {{.*}}alloc::vec::from_elem - // CHECK-NOT: call {{.*}}reserve - // CHECK-NOT: call {{.*}}__rust_alloc( - - // CHECK: ret void - vec![0; n] -} - -// CHECK-LABEL: @vec_one_scalar -#[no_mangle] -pub fn vec_one_scalar(n: usize) -> Vec { - // CHECK-NOT: call {{.*}}alloc::vec::from_elem - // CHECK-NOT: call {{.*}}reserve - // CHECK-NOT: call {{.*}}__rust_alloc_zeroed( - - // CHECK: call {{.*}}__rust_alloc( - - // CHECK-NOT: call {{.*}}alloc::vec::from_elem - // CHECK-NOT: call {{.*}}reserve - // CHECK-NOT: call {{.*}}__rust_alloc_zeroed( - - // CHECK: ret void - vec![1; n] -} - -// CHECK-LABEL: @vec_zero_rgb48 -#[no_mangle] -pub fn vec_zero_rgb48(n: usize) -> Vec<[u16; 3]> { - // CHECK-NOT: call {{.*}}alloc::vec::from_elem - // CHECK-NOT: call {{.*}}reserve - // CHECK-NOT: call {{.*}}__rust_alloc( - - // CHECK: call {{.*}}__rust_alloc_zeroed( - - // CHECK-NOT: call {{.*}}alloc::vec::from_elem - // CHECK-NOT: call {{.*}}reserve - // CHECK-NOT: call {{.*}}__rust_alloc( - - // CHECK: ret void - vec![[0, 0, 0]; n] -} - -// CHECK-LABEL: @vec_zero_array_16 -#[no_mangle] -pub fn vec_zero_array_16(n: usize) -> Vec<[i64; 16]> { - // CHECK-NOT: call {{.*}}alloc::vec::from_elem - // CHECK-NOT: call {{.*}}reserve - // CHECK-NOT: call {{.*}}__rust_alloc( - - // CHECK: call {{.*}}__rust_alloc_zeroed( - - // CHECK-NOT: call {{.*}}alloc::vec::from_elem - // CHECK-NOT: call {{.*}}reserve - // CHECK-NOT: call {{.*}}__rust_alloc( - - // CHECK: ret void - vec![[0_i64; 16]; n] -} - -// CHECK-LABEL: @vec_zero_tuple -#[no_mangle] -pub fn vec_zero_tuple(n: usize) -> Vec<(i16, u8, char)> { - // CHECK-NOT: call {{.*}}alloc::vec::from_elem - // CHECK-NOT: call {{.*}}reserve - // CHECK-NOT: call {{.*}}__rust_alloc( - - // CHECK: call {{.*}}__rust_alloc_zeroed( - - // CHECK-NOT: call {{.*}}alloc::vec::from_elem - // CHECK-NOT: call {{.*}}reserve - // CHECK-NOT: call {{.*}}__rust_alloc( - - // CHECK: ret void - vec![(0, 0, '\0'); n] -} - -// CHECK-LABEL: @vec_non_zero_tuple -#[no_mangle] -pub fn vec_non_zero_tuple(n: usize) -> Vec<(i16, u8, char)> { - // CHECK-NOT: call {{.*}}alloc::vec::from_elem - // CHECK-NOT: call {{.*}}reserve - // CHECK-NOT: call {{.*}}__rust_alloc_zeroed( - - // CHECK: call {{.*}}__rust_alloc( - - // CHECK-NOT: call {{.*}}alloc::vec::from_elem - // CHECK-NOT: call {{.*}}reserve - // CHECK-NOT: call {{.*}}__rust_alloc_zeroed( - - // CHECK: ret void - vec![(0, 0, 'A'); n] -} From 392bfc6bd34f49b51f62bd2788857610cc629dee Mon Sep 17 00:00:00 2001 From: Martin Nordholts Date: Tue, 1 Aug 2023 06:06:39 +0200 Subject: [PATCH 11/18] tests/run-make/unknown-mod-stdin: Ignore Windows The test fails on Windows with the diff - = help: to create the module `unknown`, create file "unknown.rs" or "unknown/mod.rs" + = help: to create the module `unknown`, create file "unknown.rs" or "unknown\mod.rs" There is no need to run this test on Windows, so ignore it. --- tests/run-make/unknown-mod-stdin/Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/run-make/unknown-mod-stdin/Makefile b/tests/run-make/unknown-mod-stdin/Makefile index 6a73179c51fe3..c1931765382e8 100644 --- a/tests/run-make/unknown-mod-stdin/Makefile +++ b/tests/run-make/unknown-mod-stdin/Makefile @@ -1,3 +1,5 @@ +# ignore-windows + include ../tools.mk all: From 026c4b6a65891203d25ac403d67a924c9329b962 Mon Sep 17 00:00:00 2001 From: yukang Date: Wed, 2 Aug 2023 09:56:02 +0800 Subject: [PATCH 12/18] trivial style fix --- .../rustc_resolve/src/late/diagnostics.rs | 57 +++++++++---------- 1 file changed, 27 insertions(+), 30 deletions(-) diff --git a/compiler/rustc_resolve/src/late/diagnostics.rs b/compiler/rustc_resolve/src/late/diagnostics.rs index 974580f815bd0..867d7c6f00329 100644 --- a/compiler/rustc_resolve/src/late/diagnostics.rs +++ b/compiler/rustc_resolve/src/late/diagnostics.rs @@ -555,7 +555,6 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> { } }) .collect::>(); - let crate_def_id = CRATE_DEF_ID.to_def_id(); // Try to filter out intrinsics candidates, as long as we have // some other candidates to suggest. let intrinsic_candidates: Vec<_> = candidates @@ -566,8 +565,9 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> { .collect(); if candidates.is_empty() { // Put them back if we have no more candidates to suggest... - candidates.extend(intrinsic_candidates); + candidates = intrinsic_candidates; } + let crate_def_id = CRATE_DEF_ID.to_def_id(); if candidates.is_empty() && is_expected(Res::Def(DefKind::Enum, crate_def_id)) { let mut enum_candidates: Vec<_> = self .r @@ -1008,7 +1008,7 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> { span: Span, ) { if let Some((trait_ref, self_ty)) = - self.diagnostic_metadata.currently_processing_impl_trait.clone() + self.diagnostic_metadata.currently_processing_impl_trait.clone() && let TyKind::Path(_, self_ty_path) = &self_ty.kind && let PathResult::Module(ModuleOrUniformRoot::Module(module)) = self.resolve_path(&Segment::from_path(self_ty_path), Some(TypeNS), None) @@ -1180,37 +1180,34 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> { /// return the span of whole call and the span for all arguments expect the first one (`self`). fn call_has_self_arg(&self, source: PathSource<'_>) -> Option<(Span, Option)> { let mut has_self_arg = None; - if let PathSource::Expr(Some(parent)) = source { - match &parent.kind { - ExprKind::Call(_, args) if !args.is_empty() => { - let mut expr_kind = &args[0].kind; - loop { - match expr_kind { - ExprKind::Path(_, arg_name) if arg_name.segments.len() == 1 => { - if arg_name.segments[0].ident.name == kw::SelfLower { - let call_span = parent.span; - let tail_args_span = if args.len() > 1 { - Some(Span::new( - args[1].span.lo(), - args.last().unwrap().span.hi(), - call_span.ctxt(), - None, - )) - } else { - None - }; - has_self_arg = Some((call_span, tail_args_span)); - } - break; + if let PathSource::Expr(Some(parent)) = source + && let ExprKind::Call(_, args) = &parent.kind + && !args.is_empty() { + let mut expr_kind = &args[0].kind; + loop { + match expr_kind { + ExprKind::Path(_, arg_name) if arg_name.segments.len() == 1 => { + if arg_name.segments[0].ident.name == kw::SelfLower { + let call_span = parent.span; + let tail_args_span = if args.len() > 1 { + Some(Span::new( + args[1].span.lo(), + args.last().unwrap().span.hi(), + call_span.ctxt(), + None, + )) + } else { + None + }; + has_self_arg = Some((call_span, tail_args_span)); } - ExprKind::AddrOf(_, _, expr) => expr_kind = &expr.kind, - _ => break, + break; } + ExprKind::AddrOf(_, _, expr) => expr_kind = &expr.kind, + _ => break, } } - _ => (), - } - }; + } has_self_arg } From e47cd2f250df213a17525367240eeb4740183ba0 Mon Sep 17 00:00:00 2001 From: Tshepang Mbambo Date: Wed, 2 Aug 2023 11:17:57 +0200 Subject: [PATCH 13/18] string.rs: remove "Basic usage" text Only a single example is given --- library/alloc/src/string.rs | 73 +------------------------------------ 1 file changed, 1 insertion(+), 72 deletions(-) diff --git a/library/alloc/src/string.rs b/library/alloc/src/string.rs index 9254786d1295d..ed43244ebda19 100644 --- a/library/alloc/src/string.rs +++ b/library/alloc/src/string.rs @@ -388,8 +388,6 @@ pub struct String { /// /// # Examples /// -/// Basic usage: -/// /// ``` /// // some invalid bytes, in a vector /// let bytes = vec![0, 159]; @@ -412,9 +410,8 @@ pub struct FromUtf8Error { /// This type is the error type for the [`from_utf16`] method on [`String`]. /// /// [`from_utf16`]: String::from_utf16 -/// # Examples /// -/// Basic usage: +/// # Examples /// /// ``` /// // 𝄞muic @@ -441,8 +438,6 @@ impl String { /// /// # Examples /// - /// Basic usage: - /// /// ``` /// let s = String::new(); /// ``` @@ -472,8 +467,6 @@ impl String { /// /// # Examples /// - /// Basic usage: - /// /// ``` /// let mut s = String::with_capacity(10); /// @@ -661,8 +654,6 @@ impl String { /// /// # Examples /// - /// Basic usage: - /// /// ``` /// // 𝄞music /// let v = &[0xD834, 0xDD1E, 0x006d, 0x0075, @@ -704,8 +695,6 @@ impl String { /// /// # Examples /// - /// Basic usage: - /// /// ``` /// // 𝄞music /// let v = &[0xD834, 0xDD1E, 0x006d, 0x0075, @@ -784,8 +773,6 @@ impl String { /// /// # Examples /// - /// Basic usage: - /// /// ``` /// use std::mem; /// @@ -827,8 +814,6 @@ impl String { /// /// # Examples /// - /// Basic usage: - /// /// ``` /// // some bytes, in a vector /// let sparkle_heart = vec![240, 159, 146, 150]; @@ -852,8 +837,6 @@ impl String { /// /// # Examples /// - /// Basic usage: - /// /// ``` /// let s = String::from("hello"); /// let bytes = s.into_bytes(); @@ -871,8 +854,6 @@ impl String { /// /// # Examples /// - /// Basic usage: - /// /// ``` /// let s = String::from("foo"); /// @@ -889,8 +870,6 @@ impl String { /// /// # Examples /// - /// Basic usage: - /// /// ``` /// let mut s = String::from("foobar"); /// let s_mut_str = s.as_mut_str(); @@ -910,8 +889,6 @@ impl String { /// /// # Examples /// - /// Basic usage: - /// /// ``` /// let mut s = String::from("foo"); /// @@ -966,8 +943,6 @@ impl String { /// /// # Examples /// - /// Basic usage: - /// /// ``` /// let s = String::with_capacity(10); /// @@ -1157,8 +1132,6 @@ impl String { /// /// # Examples /// - /// Basic usage: - /// /// ``` /// let mut s = String::from("foo"); /// @@ -1206,8 +1179,6 @@ impl String { /// /// # Examples /// - /// Basic usage: - /// /// ``` /// let mut s = String::from("abc"); /// @@ -1235,8 +1206,6 @@ impl String { /// /// # Examples /// - /// Basic usage: - /// /// ``` /// let s = String::from("hello"); /// @@ -1263,8 +1232,6 @@ impl String { /// /// # Examples /// - /// Basic usage: - /// /// ``` /// let mut s = String::from("hello"); /// @@ -1287,8 +1254,6 @@ impl String { /// /// # Examples /// - /// Basic usage: - /// /// ``` /// let mut s = String::from("abč"); /// @@ -1321,8 +1286,6 @@ impl String { /// /// # Examples /// - /// Basic usage: - /// /// ``` /// let mut s = String::from("abç"); /// @@ -1514,8 +1477,6 @@ impl String { /// /// # Examples /// - /// Basic usage: - /// /// ``` /// let mut s = String::with_capacity(3); /// @@ -1563,8 +1524,6 @@ impl String { /// /// # Examples /// - /// Basic usage: - /// /// ``` /// let mut s = String::from("bar"); /// @@ -1595,8 +1554,6 @@ impl String { /// /// # Examples /// - /// Basic usage: - /// /// ``` /// let mut s = String::from("hello"); /// @@ -1620,8 +1577,6 @@ impl String { /// /// # Examples /// - /// Basic usage: - /// /// ``` /// let a = String::from("foo"); /// assert_eq!(a.len(), 3); @@ -1641,8 +1596,6 @@ impl String { /// /// # Examples /// - /// Basic usage: - /// /// ``` /// let mut v = String::new(); /// assert!(v.is_empty()); @@ -1697,8 +1650,6 @@ impl String { /// /// # Examples /// - /// Basic usage: - /// /// ``` /// let mut s = String::from("foo"); /// @@ -1734,8 +1685,6 @@ impl String { /// /// # Examples /// - /// Basic usage: - /// /// ``` /// let mut s = String::from("α is alpha, β is beta"); /// let beta_offset = s.find('β').unwrap_or(s.len()); @@ -1784,8 +1733,6 @@ impl String { /// /// # Examples /// - /// Basic usage: - /// /// ``` /// let mut s = String::from("α is alpha, β is beta"); /// let beta_offset = s.find('β').unwrap_or(s.len()); @@ -1834,8 +1781,6 @@ impl String { /// /// # Examples /// - /// Basic usage: - /// /// ``` /// let s = String::from("hello"); /// @@ -1866,8 +1811,6 @@ impl String { /// /// # Examples /// - /// Simple usage: - /// /// ``` /// let x = String::from("bucket"); /// let static_ref: &'static mut str = x.leak(); @@ -1886,8 +1829,6 @@ impl FromUtf8Error { /// /// # Examples /// - /// Basic usage: - /// /// ``` /// // some invalid bytes, in a vector /// let bytes = vec![0, 159]; @@ -1910,8 +1851,6 @@ impl FromUtf8Error { /// /// # Examples /// - /// Basic usage: - /// /// ``` /// // some invalid bytes, in a vector /// let bytes = vec![0, 159]; @@ -1938,8 +1877,6 @@ impl FromUtf8Error { /// /// # Examples /// - /// Basic usage: - /// /// ``` /// // some invalid bytes, in a vector /// let bytes = vec![0, 159]; @@ -2490,8 +2427,6 @@ pub trait ToString { /// /// # Examples /// - /// Basic usage: - /// /// ``` /// let i = 5; /// let five = String::from("5"); @@ -2711,8 +2646,6 @@ impl From> for String { /// /// # Examples /// - /// Basic usage: - /// /// ``` /// let s1: String = String::from("hello world"); /// let s2: Box = s1.into_boxed_str(); @@ -2732,8 +2665,6 @@ impl From for Box { /// /// # Examples /// - /// Basic usage: - /// /// ``` /// let s1: String = String::from("hello world"); /// let s2: Box = Box::from(s1); @@ -2866,8 +2797,6 @@ impl From for Vec { /// /// # Examples /// - /// Basic usage: - /// /// ``` /// let s1 = String::from("hello world"); /// let v1 = Vec::from(s1); From 60e43bcf577c4aeb5fcb1947c8e1c6c1a9c39760 Mon Sep 17 00:00:00 2001 From: Tshepang Mbambo Date: Wed, 2 Aug 2023 12:14:43 +0200 Subject: [PATCH 14/18] str.rs: remove "Basic usage" text Only one example is given --- library/alloc/src/str.rs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/library/alloc/src/str.rs b/library/alloc/src/str.rs index 8497740990443..921ce850d1eb1 100644 --- a/library/alloc/src/str.rs +++ b/library/alloc/src/str.rs @@ -223,8 +223,6 @@ impl str { /// /// # Examples /// - /// Basic usage: - /// /// ``` /// let s = "this is a string"; /// let boxed_str = s.to_owned().into_boxed_str(); @@ -487,8 +485,6 @@ impl str { /// /// # Examples /// - /// Basic usage: - /// /// ``` /// let string = String::from("birthday gift"); /// let boxed_str = string.clone().into_boxed_str(); @@ -602,8 +598,6 @@ impl str { /// /// # Examples /// -/// Basic usage: -/// /// ``` /// let smile_utf8 = Box::new([226, 152, 186]); /// let smile = unsafe { std::str::from_boxed_utf8_unchecked(smile_utf8) }; From 5419abd4009e7e0f14c95c16de48f819563b7066 Mon Sep 17 00:00:00 2001 From: Michael Watzko Date: Mon, 31 Jul 2023 15:34:41 +0200 Subject: [PATCH 15/18] Implement Option::take_if --- library/core/src/option.rs | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/library/core/src/option.rs b/library/core/src/option.rs index 9b6ff76b24047..264a53f43dce4 100644 --- a/library/core/src/option.rs +++ b/library/core/src/option.rs @@ -1697,6 +1697,41 @@ impl Option { mem::replace(self, None) } + /// Takes the value out of the option, but only if the predicate evaluates to + /// `true` on a mutable reference to the value. + /// + /// In other words, replaces `self` with `None` if the predicate returns `true`. + /// This method operates similar to [`Option::take`] but conditional. + /// + /// # Examples + /// + /// ``` + /// #![feature(option_take_if)] + /// + /// let mut x = Some(42); + /// + /// let prev = x.take_if(|v| if *v == 42 { + /// *v += 1; + /// false + /// } else { + /// false + /// }); + /// assert_eq!(x, Some(43)); + /// assert_eq!(prev, None); + /// + /// let prev = x.take_if(|v| *v == 43); + /// assert_eq!(x, None); + /// assert_eq!(prev, Some(43)); + /// ``` + #[inline] + #[unstable(feature = "option_take_if", issue = "98934")] + pub fn take_if

(&mut self, predicate: P) -> Option + where + P: FnOnce(&mut T) -> bool, + { + if self.as_mut().map_or(false, predicate) { self.take() } else { None } + } + /// Replaces the actual value in the option by the value given in parameter, /// returning the old value if present, /// leaving a [`Some`] in its place without deinitializing either one. From eb0fcc5ad1f8e622c942334658ae9d2a9fd2203e Mon Sep 17 00:00:00 2001 From: yukang Date: Sun, 6 Aug 2023 22:28:14 +0800 Subject: [PATCH 16/18] refactor on span_look_ahead --- .../rustc_resolve/src/late/diagnostics.rs | 20 +++++++------- compiler/rustc_span/src/source_map.rs | 15 +++++------ .../src/traits/error_reporting/suggestions.rs | 26 +++++++++---------- 3 files changed, 28 insertions(+), 33 deletions(-) diff --git a/compiler/rustc_resolve/src/late/diagnostics.rs b/compiler/rustc_resolve/src/late/diagnostics.rs index 867d7c6f00329..9edcb5255b204 100644 --- a/compiler/rustc_resolve/src/late/diagnostics.rs +++ b/compiler/rustc_resolve/src/late/diagnostics.rs @@ -1008,7 +1008,7 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> { span: Span, ) { if let Some((trait_ref, self_ty)) = - self.diagnostic_metadata.currently_processing_impl_trait.clone() + self.diagnostic_metadata.currently_processing_impl_trait.clone() && let TyKind::Path(_, self_ty_path) = &self_ty.kind && let PathResult::Module(ModuleOrUniformRoot::Module(module)) = self.resolve_path(&Segment::from_path(self_ty_path), Some(TypeNS), None) @@ -1217,15 +1217,15 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> { // where a brace being opened means a block is being started. Look // ahead for the next text to see if `span` is followed by a `{`. let sm = self.r.tcx.sess.source_map(); - let sp = sm.span_look_ahead(span, None, Some(50)); - let followed_by_brace = matches!(sm.span_to_snippet(sp), Ok(ref snippet) if snippet == "{"); - // In case this could be a struct literal that needs to be surrounded - // by parentheses, find the appropriate span. - let closing_span = sm.span_look_ahead(span, Some("}"), Some(50)); - let closing_brace: Option = sm - .span_to_snippet(closing_span) - .map_or(None, |s| if s == "}" { Some(span.to(closing_span)) } else { None }); - (followed_by_brace, closing_brace) + if let Some(followed_brace_span) = sm.span_look_ahead(span, "{", Some(50)) { + // In case this could be a struct literal that needs to be surrounded + // by parentheses, find the appropriate span. + let close_brace_span = sm.span_look_ahead(followed_brace_span, "}", Some(50)); + let closing_brace = close_brace_span.map(|sp| span.to(sp)); + (true, closing_brace) + } else { + (false, None) + } } /// Provides context-dependent help for errors reported by the `smart_resolve_path_fragment` diff --git a/compiler/rustc_span/src/source_map.rs b/compiler/rustc_span/src/source_map.rs index 86716da1712fb..983b2ab04a4ae 100644 --- a/compiler/rustc_span/src/source_map.rs +++ b/compiler/rustc_span/src/source_map.rs @@ -973,24 +973,21 @@ impl SourceMap { Span::new(BytePos(start_of_next_point), end_of_next_point, sp.ctxt(), None) } - /// Returns a new span to check next none-whitespace character or some specified expected character - /// If `expect` is none, the first span of non-whitespace character is returned. - /// If `expect` presented, the first span of the character `expect` is returned - /// Otherwise, the span reached to limit is returned. - pub fn span_look_ahead(&self, span: Span, expect: Option<&str>, limit: Option) -> Span { + /// Check whether span is followed by some specified expected string in limit scope + pub fn span_look_ahead(&self, span: Span, expect: &str, limit: Option) -> Option { let mut sp = span; for _ in 0..limit.unwrap_or(100_usize) { sp = self.next_point(sp); if let Ok(ref snippet) = self.span_to_snippet(sp) { - if expect.is_some_and(|es| snippet == es) { - break; + if snippet == expect { + return Some(sp); } - if expect.is_none() && snippet.chars().any(|c| !c.is_whitespace()) { + if snippet.chars().any(|c| !c.is_whitespace()) { break; } } } - sp + None } /// Finds the width of the character, either before or after the end of provided span, diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs index 31f70bbd34dec..e62be1adbcaae 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs @@ -1428,20 +1428,18 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> { // Issue #109436, we need to add parentheses properly for method calls // for example, `foo.into()` should be `(&foo).into()` - if let Ok(snippet) = self.tcx.sess.source_map().span_to_snippet( - self.tcx.sess.source_map().span_look_ahead(span, Some("."), Some(50)), - ) { - if snippet == "." { - err.multipart_suggestion_verbose( - sugg_msg, - vec![ - (span.shrink_to_lo(), format!("({sugg_prefix}")), - (span.shrink_to_hi(), ")".to_string()), - ], - Applicability::MaybeIncorrect, - ); - return true; - } + if let Some(_) = + self.tcx.sess.source_map().span_look_ahead(span, ".", Some(50)) + { + err.multipart_suggestion_verbose( + sugg_msg, + vec![ + (span.shrink_to_lo(), format!("({sugg_prefix}")), + (span.shrink_to_hi(), ")".to_string()), + ], + Applicability::MaybeIncorrect, + ); + return true; } // Issue #104961, we need to add parentheses properly for compound expressions From 502af03445f045dade14f14e754803f02c2c5e24 Mon Sep 17 00:00:00 2001 From: Scott McMurray Date: Wed, 2 Aug 2023 12:45:52 -0700 Subject: [PATCH 17/18] Add a new `compare_bytes` intrinsic instead of calling `memcmp` directly --- .../src/intrinsics/mod.rs | 13 +++++ .../rustc_codegen_gcc/src/intrinsic/mod.rs | 14 +++++ compiler/rustc_codegen_llvm/src/context.rs | 3 +- compiler/rustc_codegen_llvm/src/intrinsic.rs | 9 ++++ .../src/interpret/intrinsics.rs | 22 ++++++++ .../rustc_hir_analysis/src/check/intrinsic.rs | 4 ++ compiler/rustc_span/src/symbol.rs | 1 + library/core/src/intrinsics.rs | 34 ++++++++++++ library/core/src/slice/cmp.rs | 21 +++----- .../miri/tests/fail/uninit_buffer.stderr | 4 +- .../fail/uninit_buffer_with_provenance.stderr | 4 +- tests/codegen/intrinsics/compare_bytes.rs | 34 ++++++++++++ tests/ui/consts/const-compare-bytes-ub.rs | 41 ++++++++++++++ tests/ui/consts/const-compare-bytes-ub.stderr | 54 +++++++++++++++++++ tests/ui/consts/const-compare-bytes.rs | 27 ++++++++++ tests/ui/proc-macro/meta-macro-hygiene.stdout | 2 +- .../nonterminal-token-hygiene.stdout | 2 +- 17 files changed, 267 insertions(+), 22 deletions(-) create mode 100644 tests/codegen/intrinsics/compare_bytes.rs create mode 100644 tests/ui/consts/const-compare-bytes-ub.rs create mode 100644 tests/ui/consts/const-compare-bytes-ub.stderr create mode 100644 tests/ui/consts/const-compare-bytes.rs diff --git a/compiler/rustc_codegen_cranelift/src/intrinsics/mod.rs b/compiler/rustc_codegen_cranelift/src/intrinsics/mod.rs index e3006b253b7a5..dcb080b9ec14b 100644 --- a/compiler/rustc_codegen_cranelift/src/intrinsics/mod.rs +++ b/compiler/rustc_codegen_cranelift/src/intrinsics/mod.rs @@ -1155,6 +1155,19 @@ fn codegen_regular_intrinsic_call<'tcx>( ret.write_cvalue(fx, CValue::by_val(is_eq_value, ret.layout())); } + sym::compare_bytes => { + intrinsic_args!(fx, args => (lhs_ptr, rhs_ptr, bytes_val); intrinsic); + let lhs_ptr = lhs_ptr.load_scalar(fx); + let rhs_ptr = rhs_ptr.load_scalar(fx); + let bytes_val = bytes_val.load_scalar(fx); + + let params = vec![AbiParam::new(fx.pointer_type); 3]; + let returns = vec![AbiParam::new(types::I32)]; + let args = &[lhs_ptr, rhs_ptr, bytes_val]; + let cmp = fx.lib_call("memcmp", params, returns, args)[0]; + ret.write_cvalue(fx, CValue::by_val(cmp, ret.layout())); + } + sym::const_allocate => { intrinsic_args!(fx, args => (_size, _align); intrinsic); diff --git a/compiler/rustc_codegen_gcc/src/intrinsic/mod.rs b/compiler/rustc_codegen_gcc/src/intrinsic/mod.rs index 68edde1382941..eca2abf2775ed 100644 --- a/compiler/rustc_codegen_gcc/src/intrinsic/mod.rs +++ b/compiler/rustc_codegen_gcc/src/intrinsic/mod.rs @@ -302,6 +302,20 @@ impl<'a, 'gcc, 'tcx> IntrinsicCallMethods<'tcx> for Builder<'a, 'gcc, 'tcx> { } } + sym::compare_bytes => { + let a = args[0].immediate(); + let b = args[1].immediate(); + let n = args[2].immediate(); + + let void_ptr_type = self.context.new_type::<*const ()>(); + let a_ptr = self.bitcast(a, void_ptr_type); + let b_ptr = self.bitcast(b, void_ptr_type); + + let builtin = self.context.get_builtin_function("memcmp"); + let cmp = self.context.new_call(None, builtin, &[a_ptr, b_ptr, n]); + self.sext(cmp, self.type_ix(32)) + } + sym::black_box => { args[0].val.store(self, result); diff --git a/compiler/rustc_codegen_llvm/src/context.rs b/compiler/rustc_codegen_llvm/src/context.rs index 3577fb2d951ba..2d23be6cd524a 100644 --- a/compiler/rustc_codegen_llvm/src/context.rs +++ b/compiler/rustc_codegen_llvm/src/context.rs @@ -891,7 +891,8 @@ impl<'ll> CodegenCx<'ll, '_> { ifn!("llvm.prefetch", fn(ptr, t_i32, t_i32, t_i32) -> void); // This isn't an "LLVM intrinsic", but LLVM's optimization passes - // recognize it like one and we assume it exists in `core::slice::cmp` + // recognize it like one (including turning it into `bcmp` sometimes) + // and we use it to implement intrinsics like `raw_eq` and `compare_bytes` match self.sess().target.arch.as_ref() { "avr" | "msp430" => ifn!("memcmp", fn(ptr, ptr, t_isize) -> t_i16), _ => ifn!("memcmp", fn(ptr, ptr, t_isize) -> t_i32), diff --git a/compiler/rustc_codegen_llvm/src/intrinsic.rs b/compiler/rustc_codegen_llvm/src/intrinsic.rs index 6f1e4c5178aae..4e86094ce3b2b 100644 --- a/compiler/rustc_codegen_llvm/src/intrinsic.rs +++ b/compiler/rustc_codegen_llvm/src/intrinsic.rs @@ -329,6 +329,15 @@ impl<'ll, 'tcx> IntrinsicCallMethods<'tcx> for Builder<'_, 'll, 'tcx> { } } + sym::compare_bytes => { + let cmp = self.call_intrinsic( + "memcmp", + &[args[0].immediate(), args[1].immediate(), args[2].immediate()], + ); + // Some targets have `memcmp` returning `i16`, but the intrinsic is always `i32`. + self.sext(cmp, self.type_ix(32)) + } + sym::black_box => { args[0].val.store(self, result); let result_val_span = [result.llval]; diff --git a/compiler/rustc_const_eval/src/interpret/intrinsics.rs b/compiler/rustc_const_eval/src/interpret/intrinsics.rs index 123eb3125f0ed..f22cd919c3695 100644 --- a/compiler/rustc_const_eval/src/interpret/intrinsics.rs +++ b/compiler/rustc_const_eval/src/interpret/intrinsics.rs @@ -261,6 +261,10 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { sym::write_bytes => { self.write_bytes_intrinsic(&args[0], &args[1], &args[2])?; } + sym::compare_bytes => { + let result = self.compare_bytes_intrinsic(&args[0], &args[1], &args[2])?; + self.write_scalar(result, dest)?; + } sym::arith_offset => { let ptr = self.read_pointer(&args[0])?; let offset_count = self.read_target_isize(&args[1])?; @@ -643,6 +647,24 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { self.write_bytes_ptr(dst, bytes) } + pub(crate) fn compare_bytes_intrinsic( + &mut self, + left: &OpTy<'tcx, >::Provenance>, + right: &OpTy<'tcx, >::Provenance>, + byte_count: &OpTy<'tcx, >::Provenance>, + ) -> InterpResult<'tcx, Scalar> { + let left = self.read_pointer(left)?; + let right = self.read_pointer(right)?; + let n = Size::from_bytes(self.read_target_usize(byte_count)?); + + let left_bytes = self.read_bytes_ptr_strip_provenance(left, n)?; + let right_bytes = self.read_bytes_ptr_strip_provenance(right, n)?; + + // `Ordering`'s discriminants are -1/0/+1, so casting does the right thing. + let result = Ord::cmp(left_bytes, right_bytes) as i32; + Ok(Scalar::from_i32(result)) + } + pub(crate) fn raw_eq_intrinsic( &mut self, lhs: &OpTy<'tcx, >::Provenance>, diff --git a/compiler/rustc_hir_analysis/src/check/intrinsic.rs b/compiler/rustc_hir_analysis/src/check/intrinsic.rs index 970efaf312c54..f89e2e5c25bf2 100644 --- a/compiler/rustc_hir_analysis/src/check/intrinsic.rs +++ b/compiler/rustc_hir_analysis/src/check/intrinsic.rs @@ -273,6 +273,10 @@ pub fn check_intrinsic_type(tcx: TyCtxt<'_>, it: &hir::ForeignItem<'_>) { ], Ty::new_unit(tcx), ), + sym::compare_bytes => { + let byte_ptr = Ty::new_imm_ptr(tcx, tcx.types.u8); + (0, vec![byte_ptr, byte_ptr, tcx.types.usize], tcx.types.i32) + } sym::write_bytes | sym::volatile_set_memory => ( 1, vec![ diff --git a/compiler/rustc_span/src/symbol.rs b/compiler/rustc_span/src/symbol.rs index 44820ae6f727c..9ea9efb047c2b 100644 --- a/compiler/rustc_span/src/symbol.rs +++ b/compiler/rustc_span/src/symbol.rs @@ -498,6 +498,7 @@ symbols! { cold, collapse_debuginfo, column, + compare_bytes, compare_exchange, compare_exchange_weak, compile_error, diff --git a/library/core/src/intrinsics.rs b/library/core/src/intrinsics.rs index d042aaf3084d6..9ef2c7cde02eb 100644 --- a/library/core/src/intrinsics.rs +++ b/library/core/src/intrinsics.rs @@ -2385,6 +2385,25 @@ extern "rust-intrinsic" { #[rustc_nounwind] pub fn raw_eq(a: &T, b: &T) -> bool; + /// Lexicographically compare `[left, left + bytes)` and `[right, right + bytes)` + /// as unsigned bytes, returning negative if `left` is less, zero if all the + /// bytes match, or positive if `right` is greater. + /// + /// This underlies things like `<[u8]>::cmp`, and will usually lower to `memcmp`. + /// + /// # Safety + /// + /// `left` and `right` must each be [valid] for reads of `bytes` bytes. + /// + /// Note that this applies to the whole range, not just until the first byte + /// that differs. That allows optimizations that can read in large chunks. + /// + /// [valid]: crate::ptr#safety + #[cfg(not(bootstrap))] + #[rustc_const_unstable(feature = "const_intrinsic_compare_bytes", issue = "none")] + #[rustc_nounwind] + pub fn compare_bytes(left: *const u8, right: *const u8, bytes: usize) -> i32; + /// See documentation of [`std::hint::black_box`] for details. /// /// [`std::hint::black_box`]: crate::hint::black_box @@ -2825,3 +2844,18 @@ pub const unsafe fn write_bytes(dst: *mut T, val: u8, count: usize) { write_bytes(dst, val, count) } } + +/// Backfill for bootstrap +#[cfg(bootstrap)] +pub unsafe fn compare_bytes(left: *const u8, right: *const u8, bytes: usize) -> i32 { + extern "C" { + fn memcmp(s1: *const u8, s2: *const u8, n: usize) -> crate::ffi::c_int; + } + + if bytes != 0 { + // SAFETY: Since bytes is non-zero, the caller has met `memcmp`'s requirements. + unsafe { memcmp(left, right, bytes).into() } + } else { + 0 + } +} diff --git a/library/core/src/slice/cmp.rs b/library/core/src/slice/cmp.rs index 7601dd3c75608..075347b80d031 100644 --- a/library/core/src/slice/cmp.rs +++ b/library/core/src/slice/cmp.rs @@ -1,22 +1,12 @@ //! Comparison traits for `[T]`. use crate::cmp::{self, BytewiseEq, Ordering}; -use crate::ffi; +use crate::intrinsics::compare_bytes; use crate::mem; use super::from_raw_parts; use super::memchr; -extern "C" { - /// Calls implementation provided memcmp. - /// - /// Interprets the data as u8. - /// - /// Returns 0 for equal, < 0 for less than and > 0 for greater - /// than. - fn memcmp(s1: *const u8, s2: *const u8, n: usize) -> ffi::c_int; -} - #[stable(feature = "rust1", since = "1.0.0")] impl PartialEq<[B]> for [A] where @@ -74,7 +64,8 @@ where } } -// Use memcmp for bytewise equality when the types allow +// When each element can be compared byte-wise, we can compare all the bytes +// from the whole size in one call to the intrinsics. impl SlicePartialEq for [A] where A: BytewiseEq, @@ -88,7 +79,7 @@ where // The two slices have been checked to have the same size above. unsafe { let size = mem::size_of_val(self); - memcmp(self.as_ptr() as *const u8, other.as_ptr() as *const u8, size) == 0 + compare_bytes(self.as_ptr() as *const u8, other.as_ptr() as *const u8, size) == 0 } } } @@ -183,7 +174,7 @@ impl SliceOrd for A { } } -// memcmp compares a sequence of unsigned bytes lexicographically. +// `compare_bytes` compares a sequence of unsigned bytes lexicographically. // this matches the order we want for [u8], but no others (not even [i8]). impl SliceOrd for u8 { #[inline] @@ -195,7 +186,7 @@ impl SliceOrd for u8 { // SAFETY: `left` and `right` are references and are thus guaranteed to be valid. // We use the minimum of both lengths which guarantees that both regions are // valid for reads in that interval. - let mut order = unsafe { memcmp(left.as_ptr(), right.as_ptr(), len) as isize }; + let mut order = unsafe { compare_bytes(left.as_ptr(), right.as_ptr(), len) as isize }; if order == 0 { order = diff; } diff --git a/src/tools/miri/tests/fail/uninit_buffer.stderr b/src/tools/miri/tests/fail/uninit_buffer.stderr index 8da532cfff05b..90210bf7f11a4 100644 --- a/src/tools/miri/tests/fail/uninit_buffer.stderr +++ b/src/tools/miri/tests/fail/uninit_buffer.stderr @@ -1,8 +1,8 @@ error: Undefined Behavior: reading memory at ALLOC[0x0..0x10], but memory is uninitialized at [0x4..0x10], and this operation requires initialized memory --> RUSTLIB/core/src/slice/cmp.rs:LL:CC | -LL | let mut order = unsafe { memcmp(left.as_ptr(), right.as_ptr(), len) as isize }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ reading memory at ALLOC[0x0..0x10], but memory is uninitialized at [0x4..0x10], and this operation requires initialized memory +LL | let mut order = unsafe { compare_bytes(left.as_ptr(), right.as_ptr(), len) as isize }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ reading memory at ALLOC[0x0..0x10], but memory is uninitialized at [0x4..0x10], and this operation requires initialized memory | = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information diff --git a/src/tools/miri/tests/fail/uninit_buffer_with_provenance.stderr b/src/tools/miri/tests/fail/uninit_buffer_with_provenance.stderr index 210fc8e109aa4..701ec6013696f 100644 --- a/src/tools/miri/tests/fail/uninit_buffer_with_provenance.stderr +++ b/src/tools/miri/tests/fail/uninit_buffer_with_provenance.stderr @@ -1,8 +1,8 @@ error: Undefined Behavior: reading memory at ALLOC[0x0..0x8], but memory is uninitialized at [0x4..0x8], and this operation requires initialized memory --> RUSTLIB/core/src/slice/cmp.rs:LL:CC | -LL | let mut order = unsafe { memcmp(left.as_ptr(), right.as_ptr(), len) as isize }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ reading memory at ALLOC[0x0..0x8], but memory is uninitialized at [0x4..0x8], and this operation requires initialized memory +LL | let mut order = unsafe { compare_bytes(left.as_ptr(), right.as_ptr(), len) as isize }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ reading memory at ALLOC[0x0..0x8], but memory is uninitialized at [0x4..0x8], and this operation requires initialized memory | = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information diff --git a/tests/codegen/intrinsics/compare_bytes.rs b/tests/codegen/intrinsics/compare_bytes.rs new file mode 100644 index 0000000000000..e69224d818c0b --- /dev/null +++ b/tests/codegen/intrinsics/compare_bytes.rs @@ -0,0 +1,34 @@ +// revisions: INT32 INT16 +// compile-flags: -O +// [INT32] ignore-16bit +// [INT16] only-16bit + +#![crate_type = "lib"] +#![feature(core_intrinsics)] + +use std::intrinsics::compare_bytes; + +#[no_mangle] +// CHECK-LABEL: @bytes_cmp( +pub unsafe fn bytes_cmp(a: *const u8, b: *const u8, n: usize) -> i32 { + // INT32: %[[TEMP:.+]] = tail call i32 @memcmp(ptr %a, ptr %b, {{i32|i64}} %n) + // INT32-NOT: sext + // INT32: ret i32 %[[TEMP]] + + // INT16: %[[TEMP1:.+]] = tail call i16 @memcmp(ptr %a, ptr %b, i16 %n) + // INT16: %[[TEMP2:.+]] = sext i16 %[[TEMP1]] to i32 + // INT16: ret i32 %[[TEMP2]] + compare_bytes(a, b, n) +} + +// Ensure that, even though there's an `sext` emitted by the intrinsic, +// that doesn't end up pessiming checks against zero. +#[no_mangle] +// CHECK-LABEL: @bytes_eq( +pub unsafe fn bytes_eq(a: *const u8, b: *const u8, n: usize) -> bool { + // CHECK: call {{.+}} @{{bcmp|memcmp}}(ptr %a, ptr %b, {{i16|i32|i64}} %n) + // CHECK-NOT: sext + // INT32: icmp eq i32 + // INT16: icmp eq i16 + compare_bytes(a, b, n) == 0_i32 +} diff --git a/tests/ui/consts/const-compare-bytes-ub.rs b/tests/ui/consts/const-compare-bytes-ub.rs new file mode 100644 index 0000000000000..2b4062fd22bf3 --- /dev/null +++ b/tests/ui/consts/const-compare-bytes-ub.rs @@ -0,0 +1,41 @@ +// check-fail + +#![feature(core_intrinsics)] +#![feature(const_intrinsic_compare_bytes)] +use std::intrinsics::compare_bytes; +use std::mem::MaybeUninit; + +fn main() { + const LHS_NULL: i32 = unsafe { + compare_bytes(0 as *const u8, 2 as *const u8, 0) + //~^ ERROR evaluation of constant value failed + }; + const RHS_NULL: i32 = unsafe { + compare_bytes(1 as *const u8, 0 as *const u8, 0) + //~^ ERROR evaluation of constant value failed + }; + const DANGLING_PTR_NON_ZERO_LENGTH: i32 = unsafe { + compare_bytes(1 as *const u8, 2 as *const u8, 1) + //~^ ERROR evaluation of constant value failed + }; + const LHS_OUT_OF_BOUNDS: i32 = unsafe { + compare_bytes([1, 2, 3].as_ptr(), [1, 2, 3, 4].as_ptr(), 4) + //~^ ERROR evaluation of constant value failed + }; + const RHS_OUT_OF_BOUNDS: i32 = unsafe { + compare_bytes([1, 2, 3, 4].as_ptr(), [1, 2, 3].as_ptr(), 4) + //~^ ERROR evaluation of constant value failed + }; + const LHS_UNINIT: i32 = unsafe { + compare_bytes(MaybeUninit::uninit().as_ptr(), [1].as_ptr(), 1) + //~^ ERROR evaluation of constant value failed + }; + const RHS_UNINIT: i32 = unsafe { + compare_bytes([1].as_ptr(), MaybeUninit::uninit().as_ptr(), 1) + //~^ ERROR evaluation of constant value failed + }; + const WITH_PROVENANCE: i32 = unsafe { + compare_bytes([&1].as_ptr().cast(), [&2].as_ptr().cast(), std::mem::size_of::()) + //~^ ERROR evaluation of constant value failed + }; +} diff --git a/tests/ui/consts/const-compare-bytes-ub.stderr b/tests/ui/consts/const-compare-bytes-ub.stderr new file mode 100644 index 0000000000000..54fafded07bad --- /dev/null +++ b/tests/ui/consts/const-compare-bytes-ub.stderr @@ -0,0 +1,54 @@ +error[E0080]: evaluation of constant value failed + --> $DIR/const-compare-bytes-ub.rs:10:9 + | +LL | compare_bytes(0 as *const u8, 2 as *const u8, 0) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: null pointer is a dangling pointer (it has no provenance) + +error[E0080]: evaluation of constant value failed + --> $DIR/const-compare-bytes-ub.rs:14:9 + | +LL | compare_bytes(1 as *const u8, 0 as *const u8, 0) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: null pointer is a dangling pointer (it has no provenance) + +error[E0080]: evaluation of constant value failed + --> $DIR/const-compare-bytes-ub.rs:18:9 + | +LL | compare_bytes(1 as *const u8, 2 as *const u8, 1) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: 0x1[noalloc] is a dangling pointer (it has no provenance) + +error[E0080]: evaluation of constant value failed + --> $DIR/const-compare-bytes-ub.rs:22:9 + | +LL | compare_bytes([1, 2, 3].as_ptr(), [1, 2, 3, 4].as_ptr(), 4) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: alloc6 has size 3, so pointer to 4 bytes starting at offset 0 is out-of-bounds + +error[E0080]: evaluation of constant value failed + --> $DIR/const-compare-bytes-ub.rs:26:9 + | +LL | compare_bytes([1, 2, 3, 4].as_ptr(), [1, 2, 3].as_ptr(), 4) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: alloc13 has size 3, so pointer to 4 bytes starting at offset 0 is out-of-bounds + +error[E0080]: evaluation of constant value failed + --> $DIR/const-compare-bytes-ub.rs:30:9 + | +LL | compare_bytes(MaybeUninit::uninit().as_ptr(), [1].as_ptr(), 1) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ reading memory at alloc17[0x0..0x1], but memory is uninitialized at [0x0..0x1], and this operation requires initialized memory + +error[E0080]: evaluation of constant value failed + --> $DIR/const-compare-bytes-ub.rs:34:9 + | +LL | compare_bytes([1].as_ptr(), MaybeUninit::uninit().as_ptr(), 1) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ reading memory at alloc25[0x0..0x1], but memory is uninitialized at [0x0..0x1], and this operation requires initialized memory + +error[E0080]: evaluation of constant value failed + --> $DIR/const-compare-bytes-ub.rs:38:9 + | +LL | compare_bytes([&1].as_ptr().cast(), [&2].as_ptr().cast(), std::mem::size_of::()) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into integer + | + = help: this code performed an operation that depends on the underlying bytes representing a pointer + = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported + +error: aborting due to 8 previous errors + +For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/consts/const-compare-bytes.rs b/tests/ui/consts/const-compare-bytes.rs new file mode 100644 index 0000000000000..74e29f8138669 --- /dev/null +++ b/tests/ui/consts/const-compare-bytes.rs @@ -0,0 +1,27 @@ +// run-pass + +#![feature(core_intrinsics)] +#![feature(const_intrinsic_compare_bytes)] +use std::intrinsics::compare_bytes; + +fn main() { + const A: i32 = unsafe { + compare_bytes(1 as *const u8, 2 as *const u8, 0) + }; + assert_eq!(A, 0); + + const B: i32 = unsafe { + compare_bytes([1, 2].as_ptr(), [1, 3].as_ptr(), 1) + }; + assert_eq!(B, 0); + + const C: i32 = unsafe { + compare_bytes([1, 2, 9].as_ptr(), [1, 3, 8].as_ptr(), 2) + }; + assert!(C < 0); + + const D: i32 = unsafe { + compare_bytes([1, 3, 8].as_ptr(), [1, 2, 9].as_ptr(), 2) + }; + assert!(D > 0); +} diff --git a/tests/ui/proc-macro/meta-macro-hygiene.stdout b/tests/ui/proc-macro/meta-macro-hygiene.stdout index e476a8024fd77..ac65ba0751238 100644 --- a/tests/ui/proc-macro/meta-macro-hygiene.stdout +++ b/tests/ui/proc-macro/meta-macro-hygiene.stdout @@ -18,7 +18,7 @@ Respanned: TokenStream [Ident { ident: "$crate", span: $DIR/auxiliary/make-macro use core /* 0#1 */::prelude /* 0#1 */::rust_2018 /* 0#1 */::*; #[macro_use /* 0#1 */] extern crate core /* 0#1 */; -extern crate compiler_builtins /* 444 */ as _ /* 0#1 */; +extern crate compiler_builtins /* 445 */ as _ /* 0#1 */; // Don't load unnecessary hygiene information from std extern crate std /* 0#0 */; diff --git a/tests/ui/proc-macro/nonterminal-token-hygiene.stdout b/tests/ui/proc-macro/nonterminal-token-hygiene.stdout index 23a2100423821..4031eb98a38d4 100644 --- a/tests/ui/proc-macro/nonterminal-token-hygiene.stdout +++ b/tests/ui/proc-macro/nonterminal-token-hygiene.stdout @@ -39,7 +39,7 @@ PRINT-BANG INPUT (DEBUG): TokenStream [ use ::core /* 0#1 */::prelude /* 0#1 */::rust_2015 /* 0#1 */::*; #[macro_use /* 0#1 */] extern crate core /* 0#2 */; -extern crate compiler_builtins /* 444 */ as _ /* 0#2 */; +extern crate compiler_builtins /* 445 */ as _ /* 0#2 */; // Don't load unnecessary hygiene information from std extern crate std /* 0#0 */; From 75277a6606e8c7443ccd3fd1a2562c166fed7298 Mon Sep 17 00:00:00 2001 From: scottmcm Date: Fri, 4 Aug 2023 06:22:50 +0000 Subject: [PATCH 18/18] Apply suggestions from code review Co-authored-by: Ralf Jung --- compiler/rustc_codegen_cranelift/src/intrinsics/mod.rs | 1 + compiler/rustc_codegen_gcc/src/intrinsic/mod.rs | 1 + compiler/rustc_codegen_llvm/src/intrinsic.rs | 1 + 3 files changed, 3 insertions(+) diff --git a/compiler/rustc_codegen_cranelift/src/intrinsics/mod.rs b/compiler/rustc_codegen_cranelift/src/intrinsics/mod.rs index dcb080b9ec14b..36e9ba9c7f8e4 100644 --- a/compiler/rustc_codegen_cranelift/src/intrinsics/mod.rs +++ b/compiler/rustc_codegen_cranelift/src/intrinsics/mod.rs @@ -1164,6 +1164,7 @@ fn codegen_regular_intrinsic_call<'tcx>( let params = vec![AbiParam::new(fx.pointer_type); 3]; let returns = vec![AbiParam::new(types::I32)]; let args = &[lhs_ptr, rhs_ptr, bytes_val]; + // Here we assume that the `memcmp` provided by the target is a NOP for size 0. let cmp = fx.lib_call("memcmp", params, returns, args)[0]; ret.write_cvalue(fx, CValue::by_val(cmp, ret.layout())); } diff --git a/compiler/rustc_codegen_gcc/src/intrinsic/mod.rs b/compiler/rustc_codegen_gcc/src/intrinsic/mod.rs index eca2abf2775ed..f8c32c6dbbb56 100644 --- a/compiler/rustc_codegen_gcc/src/intrinsic/mod.rs +++ b/compiler/rustc_codegen_gcc/src/intrinsic/mod.rs @@ -311,6 +311,7 @@ impl<'a, 'gcc, 'tcx> IntrinsicCallMethods<'tcx> for Builder<'a, 'gcc, 'tcx> { let a_ptr = self.bitcast(a, void_ptr_type); let b_ptr = self.bitcast(b, void_ptr_type); + // Here we assume that the `memcmp` provided by the target is a NOP for size 0. let builtin = self.context.get_builtin_function("memcmp"); let cmp = self.context.new_call(None, builtin, &[a_ptr, b_ptr, n]); self.sext(cmp, self.type_ix(32)) diff --git a/compiler/rustc_codegen_llvm/src/intrinsic.rs b/compiler/rustc_codegen_llvm/src/intrinsic.rs index 4e86094ce3b2b..a9b06030e70a6 100644 --- a/compiler/rustc_codegen_llvm/src/intrinsic.rs +++ b/compiler/rustc_codegen_llvm/src/intrinsic.rs @@ -330,6 +330,7 @@ impl<'ll, 'tcx> IntrinsicCallMethods<'tcx> for Builder<'_, 'll, 'tcx> { } sym::compare_bytes => { + // Here we assume that the `memcmp` provided by the target is a NOP for size 0. let cmp = self.call_intrinsic( "memcmp", &[args[0].immediate(), args[1].immediate(), args[2].immediate()],