]>
git.proxmox.com Git - rustc.git/blob - tests/ui/coercion/coerce-unsize-subtype.rs
3 // pretty-expanded FIXME #23616
7 fn lub_short
<'a
, T
>(_
: &[&'a T
], _
: &[&'a T
]) {}
9 // The two arguments are a subtype of their LUB, after coercion.
10 fn long_and_short
<'a
, T
>(xs
: &[&'
static T
; 1], ys
: &[&'a T
; 1]) {
14 // The argument coerces to a subtype of the return type.
15 fn long_to_short
<'a
, 'b
, T
>(xs
: &'b
[&'
static T
; 1]) -> &'b
[&'a T
] {
19 // Rc<T> is covariant over T just like &T.
20 fn long_to_short_rc
<'a
, T
>(xs
: Rc
<[&'
static T
; 1]>) -> Rc
<[&'a T
]> {
24 // LUB-coercion (if-else/match/array) coerces `xs: &'b [&'static T: N]`
25 // to a subtype of the LUB of `xs` and `ys` (i.e., `&'b [&'a T]`),
26 // regardless of the order they appear (in if-else/match/array).
27 fn long_and_short_lub1
<'a
, 'b
, T
>(xs
: &'b
[&'
static T
; 1], ys
: &'b
[&'a T
]) {
28 let _order1
= [xs
, ys
];
29 let _order2
= [ys
, xs
];
32 // LUB-coercion should also have the exact same effect when `&'b [&'a T; N]`
33 // needs to be coerced, i.e., the resulting type is not &'b [&'static T], but
34 // rather the `&'b [&'a T]` LUB.
35 fn long_and_short_lub2
<'a
, 'b
, T
>(xs
: &'b
[&'
static T
], ys
: &'b
[&'a T
; 1]) {
36 let _order1
= [xs
, ys
];
37 let _order2
= [ys
, xs
];