diff options
Diffstat (limited to 'tests/ui/variance/variance-use-covariant-struct-2.rs')
-rw-r--r-- | tests/ui/variance/variance-use-covariant-struct-2.rs | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/ui/variance/variance-use-covariant-struct-2.rs b/tests/ui/variance/variance-use-covariant-struct-2.rs new file mode 100644 index 000000000..ecd2204c9 --- /dev/null +++ b/tests/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() { } |