summaryrefslogtreecommitdiffstats
path: root/tests/ui/feature-gates/feature-gate-object_safe_for_dispatch.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:13 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:13 +0000
commit218caa410aa38c29984be31a5229b9fa717560ee (patch)
treec54bd55eeb6e4c508940a30e94c0032fbd45d677 /tests/ui/feature-gates/feature-gate-object_safe_for_dispatch.rs
parentReleasing progress-linux version 1.67.1+dfsg1-1~progress7.99u1. (diff)
downloadrustc-218caa410aa38c29984be31a5229b9fa717560ee.tar.xz
rustc-218caa410aa38c29984be31a5229b9fa717560ee.zip
Merging upstream version 1.68.2+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/ui/feature-gates/feature-gate-object_safe_for_dispatch.rs')
-rw-r--r--tests/ui/feature-gates/feature-gate-object_safe_for_dispatch.rs41
1 files changed, 41 insertions, 0 deletions
diff --git a/tests/ui/feature-gates/feature-gate-object_safe_for_dispatch.rs b/tests/ui/feature-gates/feature-gate-object_safe_for_dispatch.rs
new file mode 100644
index 000000000..37348e476
--- /dev/null
+++ b/tests/ui/feature-gates/feature-gate-object_safe_for_dispatch.rs
@@ -0,0 +1,41 @@
+// Test that the use of the non object-safe trait objects
+// are gated by `object_safe_for_dispatch` feature gate.
+
+trait NonObjectSafe1: Sized {}
+
+trait NonObjectSafe2 {
+ fn static_fn() {}
+}
+
+trait NonObjectSafe3 {
+ fn foo<T>(&self);
+}
+
+trait NonObjectSafe4 {
+ fn foo(&self, s: &Self);
+}
+
+fn takes_non_object_safe_ref<T>(obj: &dyn NonObjectSafe1) {
+ //~^ ERROR E0038
+}
+
+fn return_non_object_safe_ref() -> &'static dyn NonObjectSafe2 {
+ //~^ ERROR E0038
+ loop {}
+}
+
+fn takes_non_object_safe_box(obj: Box<dyn NonObjectSafe3>) {
+ //~^ ERROR E0038
+}
+
+fn return_non_object_safe_rc() -> std::rc::Rc<dyn NonObjectSafe4> {
+ //~^ ERROR E0038
+ loop {}
+}
+
+trait Trait {}
+
+impl Trait for dyn NonObjectSafe1 {}
+//~^ ERROR E0038
+
+fn main() {}