rust/tests/ui/variance/variance-use-contravariant-struct-1.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

16 lines
339 B
Rust
Raw Normal View History

// Test various uses of structs with distinct variances to make sure
// they permit lifetimes to be approximated as expected.
struct SomeStruct<T>(fn(T));
fn foo<'min,'max>(v: SomeStruct<&'max ()>)
-> SomeStruct<&'min ()>
where 'max : 'min
{
2022-04-01 21:12:17 -05:00
v
2022-04-01 12:13:25 -05:00
//~^ ERROR lifetime may not live long enough
}
fn main() { }