about summary refs log tree commit diff
path: root/tests/ui/unsized-locals/by-value-trait-object-safety-withdefault.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/unsized-locals/by-value-trait-object-safety-withdefault.rs')
-rw-r--r--tests/ui/unsized-locals/by-value-trait-object-safety-withdefault.rs23
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/ui/unsized-locals/by-value-trait-object-safety-withdefault.rs b/tests/ui/unsized-locals/by-value-trait-object-safety-withdefault.rs
new file mode 100644
index 00000000000..957991f853b
--- /dev/null
+++ b/tests/ui/unsized-locals/by-value-trait-object-safety-withdefault.rs
@@ -0,0 +1,23 @@
+// run-pass
+
+#![allow(incomplete_features)]
+#![feature(unsized_locals, unsized_fn_params)]
+
+pub trait Foo {
+    fn foo(self) -> String {
+        format!("hello")
+    }
+}
+
+struct A;
+
+impl Foo for A {}
+
+fn main() {
+    let x = *(Box::new(A) as Box<dyn Foo>);
+    assert_eq!(x.foo(), format!("hello"));
+
+    // I'm not sure whether we want this to work
+    let x = Box::new(A) as Box<dyn Foo>;
+    assert_eq!(x.foo(), format!("hello"));
+}