about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorMatthias Krüger <476013+matthiaskrgr@users.noreply.github.com>2025-04-30 10:18:28 +0200
committerGitHub <noreply@github.com>2025-04-30 10:18:28 +0200
commit9625096d2c429649cb712182858b34b6a5ca39e2 (patch)
tree53df6f39a276c03b577ed18e6b3cd301552b0121 /tests
parent254f050eb43ac5ceb00b35e77150bc792d815359 (diff)
parenta1c70590b26943370975dd04986739901a31f5db (diff)
downloadrust-9625096d2c429649cb712182858b34b6a5ca39e2.tar.gz
rust-9625096d2c429649cb712182858b34b6a5ca39e2.zip
Rollup merge of #140445 - oli-obk:const-manually-drop, r=fee1-dead
Treat ManuallyDrop as ~const Destruct

cc https://github.com/rust-lang/rust/issues/133214#issuecomment-2838078133

r? ```@compiler-errors```

cc ```@fee1-dead```
Diffstat (limited to 'tests')
-rw-r--r--tests/ui/traits/const-traits/drop-manually-drop-no-drop-impl.rs17
-rw-r--r--tests/ui/traits/const-traits/drop-manually-drop.rs24
2 files changed, 41 insertions, 0 deletions
diff --git a/tests/ui/traits/const-traits/drop-manually-drop-no-drop-impl.rs b/tests/ui/traits/const-traits/drop-manually-drop-no-drop-impl.rs
new file mode 100644
index 00000000000..060a543d6c3
--- /dev/null
+++ b/tests/ui/traits/const-traits/drop-manually-drop-no-drop-impl.rs
@@ -0,0 +1,17 @@
+//@[new] compile-flags: -Znext-solver
+//@ revisions: old new
+//@ check-pass
+
+use std::mem::ManuallyDrop;
+
+struct Moose;
+
+impl Drop for Moose {
+    fn drop(&mut self) {}
+}
+
+struct ConstDropper<T>(ManuallyDrop<T>);
+
+const fn foo(_var: ConstDropper<Moose>) {}
+
+fn main() {}
diff --git a/tests/ui/traits/const-traits/drop-manually-drop.rs b/tests/ui/traits/const-traits/drop-manually-drop.rs
new file mode 100644
index 00000000000..62e8a815f10
--- /dev/null
+++ b/tests/ui/traits/const-traits/drop-manually-drop.rs
@@ -0,0 +1,24 @@
+//@[new] compile-flags: -Znext-solver
+//@ revisions: old new
+//@ check-pass
+
+#![feature(const_destruct)]
+#![feature(const_trait_impl)]
+
+use std::mem::ManuallyDrop;
+
+struct Moose;
+
+impl Drop for Moose {
+    fn drop(&mut self) {}
+}
+
+struct ConstDropper<T>(ManuallyDrop<T>);
+
+impl<T> const Drop for ConstDropper<T> {
+    fn drop(&mut self) {}
+}
+
+const fn foo(_var: ConstDropper<Moose>) {}
+
+fn main() {}