]> git.proxmox.com Git - rustc.git/blame - src/test/ui/variance/variance-contravariant-arg-object.rs
New upstream version 1.63.0+dfsg1
[rustc.git] / src / test / ui / variance / variance-contravariant-arg-object.rs
CommitLineData
85aaf69f 1#![allow(dead_code)]
223e47cc 2
9346a6ac
AL
3// Test that even when `T` is only used in contravariant position, it
4// is treated as invariant.
5
85aaf69f
SL
6trait Get<T> : 'static {
7 fn get(&self, t: T);
8}
1a4d82fc 9
dc9dc135
XL
10fn get_min_from_max<'min, 'max>(v: Box<dyn Get<&'max i32>>)
11 -> Box<dyn Get<&'min i32>>
85aaf69f
SL
12 where 'max : 'min
13{
04454e1e 14 v
923072b8 15 //~^ ERROR lifetime may not live long enough
85aaf69f
SL
16}
17
923072b8
FG
18fn get_max_from_min<'min, 'max>(v: Box<dyn Get<&'min i32>>)
19 -> Box<dyn Get<&'max i32>>
85aaf69f
SL
20 where 'max : 'min
21{
9346a6ac 22 // Previously OK:
04454e1e 23 v
923072b8 24 //~^ ERROR lifetime may not live long enough
85aaf69f 25}
223e47cc
LB
26
27fn main() { }