summaryrefslogtreecommitdiffstats
path: root/tests/ui/object-lifetime/object-lifetime-default-default-to-static.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/object-lifetime/object-lifetime-default-default-to-static.rs')
-rw-r--r--tests/ui/object-lifetime/object-lifetime-default-default-to-static.rs35
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/ui/object-lifetime/object-lifetime-default-default-to-static.rs b/tests/ui/object-lifetime/object-lifetime-default-default-to-static.rs
new file mode 100644
index 000000000..467767ae5
--- /dev/null
+++ b/tests/ui/object-lifetime/object-lifetime-default-default-to-static.rs
@@ -0,0 +1,35 @@
+// run-pass
+// Test that `Box<Test>` is equivalent to `Box<Test+'static>`, both in
+// fields and fn arguments.
+
+// pretty-expanded FIXME #23616
+
+#![allow(dead_code)]
+
+trait Test {
+ fn foo(&self) { }
+}
+
+struct SomeStruct {
+ t: Box<dyn Test>,
+ u: Box<dyn Test+'static>,
+}
+
+fn a(t: Box<dyn Test>, mut ss: SomeStruct) {
+ ss.t = t;
+}
+
+fn b(t: Box<dyn Test+'static>, mut ss: SomeStruct) {
+ ss.t = t;
+}
+
+fn c(t: Box<dyn Test>, mut ss: SomeStruct) {
+ ss.u = t;
+}
+
+fn d(t: Box<dyn Test+'static>, mut ss: SomeStruct) {
+ ss.u = t;
+}
+
+fn main() {
+}