diff options
| author | bors <bors@rust-lang.org> | 2024-03-28 00:30:46 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-03-28 00:30:46 +0000 |
| commit | d779a7a25f67fced5f8fea232ef407c5b228a22f (patch) | |
| tree | 273af65bafe1ecb2a8d46abba13e3415c253e570 /tests/codegen | |
| parent | 9d709549481f77a8ab3111e7da2156d8d8181cdb (diff) | |
| parent | 145211eeb8af769630017b5df188b17f7014d1f2 (diff) | |
| download | rust-d779a7a25f67fced5f8fea232ef407c5b228a22f.tar.gz rust-d779a7a25f67fced5f8fea232ef407c5b228a22f.zip | |
Auto merge of #123147 - matthiaskrgr:rollup-2t5ot36, r=matthiaskrgr
Rollup of 8 pull requests Successful merges: - #121943 (Clarify atomic bit validity) - #123075 (CFI: Fix drop and drop_in_place) - #123101 (Delegation: fix ICE on wrong `Self` instantiation) - #123130 (Load missing type of impl associated constant from trait definition) - #123133 (chore: fix some comments) - #123136 (Some wording improvement) - #123139 (`num::NonZero::get` can be 1 transmute instead of 2) - #123142 (Let nils know about changes to target docs) r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'tests/codegen')
| -rw-r--r-- | tests/codegen/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-drop-in-place.rs | 27 | ||||
| -rw-r--r-- | tests/codegen/sanitizer/kcfi/emit-type-metadata-trait-objects.rs | 2 |
2 files changed, 29 insertions, 0 deletions
diff --git a/tests/codegen/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-drop-in-place.rs b/tests/codegen/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-drop-in-place.rs new file mode 100644 index 00000000000..3ec1988edd6 --- /dev/null +++ b/tests/codegen/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-drop-in-place.rs @@ -0,0 +1,27 @@ +// Verifies that type metadata identifiers for drop functions are emitted correctly. +// +//@ needs-sanitizer-cfi +//@ compile-flags: -Clto -Cno-prepopulate-passes -Copt-level=0 -Zsanitizer=cfi -Ctarget-feature=-crt-static + +#![crate_type="lib"] + +// CHECK-LABEL: define{{.*}}4core3ptr47drop_in_place$LT$dyn$u20$core..marker..Send$GT$ +// CHECK-SAME: {{.*}}!type ![[TYPE1:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +// CHECK: call i1 @llvm.type.test(ptr {{%.+}}, metadata !"_ZTSFvPu3dynIu{{[0-9]+}}NtNtNtC{{[[:print:]]+}}_4core3ops4drop4Dropu6regionEE") + +struct EmptyDrop; +// CHECK: define{{.*}}4core3ptr{{[0-9]+}}drop_in_place$LT${{.*}}EmptyDrop$GT${{.*}}!type ![[TYPE1]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} + +struct NonEmptyDrop; + +impl Drop for NonEmptyDrop { + fn drop(&mut self) {} + // CHECK: define{{.*}}4core3ptr{{[0-9]+}}drop_in_place$LT${{.*}}NonEmptyDrop$GT${{.*}}!type ![[TYPE1]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +} + +pub fn foo() { + let _ = Box::new(EmptyDrop) as Box<dyn Send>; + let _ = Box::new(NonEmptyDrop) as Box<dyn Send>; +} + +// CHECK: ![[TYPE1]] = !{i64 0, !"_ZTSFvPu3dynIu{{[0-9]+}}NtNtNtC{{[[:print:]]+}}_4core3ops4drop4Dropu6regionEE"} diff --git a/tests/codegen/sanitizer/kcfi/emit-type-metadata-trait-objects.rs b/tests/codegen/sanitizer/kcfi/emit-type-metadata-trait-objects.rs index f08c9e6702e..f9c7cca3989 100644 --- a/tests/codegen/sanitizer/kcfi/emit-type-metadata-trait-objects.rs +++ b/tests/codegen/sanitizer/kcfi/emit-type-metadata-trait-objects.rs @@ -29,6 +29,8 @@ impl<'a, 'b: 'a, T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<&'a U> for &'b trait Freeze { } #[lang="drop_in_place"] fn drop_in_place_fn<T>() { } +#[lang="drop"] +trait Drop { fn drop(&mut self); } pub trait Trait1 { fn foo(&self); |
