about summary refs log tree commit diff
path: root/tests/ui/self
diff options
context:
space:
mode:
authorMichael Goulet <michael@errs.io>2025-02-04 01:50:31 +0000
committerMichael Goulet <michael@errs.io>2025-02-04 01:50:31 +0000
commit0b26dc0b51c87a90ce61f50dd7141ff451513b23 (patch)
tree2897fbb63fb407124d3b62fa4fecc46d9548a3af /tests/ui/self
parentf2c4ccd852f68fb36dedc033239cb7c0fb1921ef (diff)
downloadrust-0b26dc0b51c87a90ce61f50dd7141ff451513b23.tar.gz
rust-0b26dc0b51c87a90ce61f50dd7141ff451513b23.zip
Remove unnecessary layout assertions for object-safe receivers
Diffstat (limited to 'tests/ui/self')
-rw-r--r--tests/ui/self/dispatch-from-dyn-layout-2.rs16
-rw-r--r--tests/ui/self/dispatch-from-dyn-layout-3.rs19
-rw-r--r--tests/ui/self/dispatch-from-dyn-layout.rs15
3 files changed, 50 insertions, 0 deletions
diff --git a/tests/ui/self/dispatch-from-dyn-layout-2.rs b/tests/ui/self/dispatch-from-dyn-layout-2.rs
new file mode 100644
index 00000000000..cd52f060dc8
--- /dev/null
+++ b/tests/ui/self/dispatch-from-dyn-layout-2.rs
@@ -0,0 +1,16 @@
+//@ check-pass
+// Regression test for #90110.
+
+// Make sure that object safety checking doesn't freak out when
+// we have impossible-to-satisfy `Sized` predicates.
+
+trait Parser
+where
+    for<'a> (dyn Parser + 'a): Sized,
+{
+    fn parse_line(&self);
+}
+
+fn foo(_: &dyn Parser) {}
+
+fn main() {}
diff --git a/tests/ui/self/dispatch-from-dyn-layout-3.rs b/tests/ui/self/dispatch-from-dyn-layout-3.rs
new file mode 100644
index 00000000000..6878a4f4ac2
--- /dev/null
+++ b/tests/ui/self/dispatch-from-dyn-layout-3.rs
@@ -0,0 +1,19 @@
+//@ check-pass
+
+// Make sure that object safety checking doesn't freak out when
+// we have impossible-to-satisfy `DispatchFromDyn` predicates.
+
+#![feature(dispatch_from_dyn)]
+#![feature(arbitrary_self_types)]
+
+use std::ops::Deref;
+use std::ops::DispatchFromDyn;
+
+trait Trait<T: Deref<Target = Self>>
+where
+    for<'a> &'a T: DispatchFromDyn<&'a T>,
+{
+    fn foo(self: &T) -> Box<dyn Trait<T>>;
+}
+
+fn main() {}
diff --git a/tests/ui/self/dispatch-from-dyn-layout.rs b/tests/ui/self/dispatch-from-dyn-layout.rs
new file mode 100644
index 00000000000..468dc89a73e
--- /dev/null
+++ b/tests/ui/self/dispatch-from-dyn-layout.rs
@@ -0,0 +1,15 @@
+//@ check-pass
+// Regression test for #57276.
+
+// Make sure that object safety checking doesn't freak out when
+// we have impossible-to-satisfy `DispatchFromDyn` predicates.
+
+#![feature(arbitrary_self_types, dispatch_from_dyn)]
+
+use std::ops::{Deref, DispatchFromDyn};
+
+trait Trait<T: Deref<Target = Self> + DispatchFromDyn<T>> {
+    fn foo(self: T) -> dyn Trait<T>;
+}
+
+fn main() {}