summaryrefslogtreecommitdiffstats
path: root/src/test/ui/variance/variance-use-covariant-struct-2.rs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/test/ui/variance/variance-use-covariant-struct-2.rs16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/test/ui/variance/variance-use-covariant-struct-2.rs b/src/test/ui/variance/variance-use-covariant-struct-2.rs
new file mode 100644
index 000000000..ecd2204c9
--- /dev/null
+++ b/src/test/ui/variance/variance-use-covariant-struct-2.rs
@@ -0,0 +1,16 @@
+// Test that a covariant struct permits the lifetime of a reference to
+// be shortened.
+
+#![allow(dead_code)]
+// build-pass (FIXME(62277): could be check-pass?)
+
+struct SomeStruct<T>(T);
+
+fn foo<'min,'max>(v: SomeStruct<&'max ()>)
+ -> SomeStruct<&'min ()>
+ where 'max : 'min
+{
+ v
+}
+
+fn main() { }