summaryrefslogtreecommitdiffstats
path: root/tests/ui/variance/variance-use-covariant-struct-1.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/variance/variance-use-covariant-struct-1.rs')
-rw-r--r--tests/ui/variance/variance-use-covariant-struct-1.rs14
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/ui/variance/variance-use-covariant-struct-1.rs b/tests/ui/variance/variance-use-covariant-struct-1.rs
new file mode 100644
index 000000000..f0fd7b26e
--- /dev/null
+++ b/tests/ui/variance/variance-use-covariant-struct-1.rs
@@ -0,0 +1,14 @@
+// Test that a covariant struct does not permit the lifetime of a
+// reference to be enlarged.
+
+struct SomeStruct<T>(T);
+
+fn foo<'min,'max>(v: SomeStruct<&'min ()>)
+ -> SomeStruct<&'max ()>
+ where 'max : 'min
+{
+ v
+ //~^ ERROR lifetime may not live long enough
+}
+
+fn main() { }