]> git.lizzy.rs Git - rust.git/blob - tests/ui/nll/user-annotations/issue-57731-ascibed-coupled-types.rs
Rollup merge of #106144 - tgross35:patch-1, r=Mark-Simulacrum
[rust.git] / tests / ui / nll / user-annotations / issue-57731-ascibed-coupled-types.rs
1 // Check that repeated type variables are correctly handled
2
3 #![allow(unused)]
4 #![feature(type_ascription)]
5
6 type PairUncoupled<'a, 'b, T> = (&'a T, &'b T);
7 type PairCoupledTypes<T> = (T, T);
8 type PairCoupledRegions<'a, T> = (&'a T, &'a T);
9
10 fn uncoupled_wilds_rhs<'a>(_x: &'a u32, s: &'static u32) -> &'static u32 {
11     let ((y, _z),) = type_ascribe!(((s, _x),), (PairUncoupled<_>,));
12     y // OK
13 }
14
15 fn coupled_wilds_rhs<'a>(_x: &'a u32, s: &'static u32) -> &'static u32 {
16     let ((y, _z),) = type_ascribe!(((s, _x),), (PairCoupledTypes<_>,));
17     y //~ ERROR lifetime may not live long enough
18 }
19
20 fn coupled_regions_rhs<'a>(_x: &'a u32, s: &'static u32) -> &'static u32 {
21     let ((y, _z),) = type_ascribe!(((s, _x),), (PairCoupledRegions<_>,));
22     y //~ ERROR lifetime may not live long enough
23 }
24
25 fn cast_uncoupled_wilds_rhs<'a>(_x: &'a u32, s: &'static u32) -> &'static u32 {
26     let ((y, _z),) = ((s, _x),) as (PairUncoupled<_>,);
27     y // OK
28 }
29
30 fn cast_coupled_wilds_rhs<'a>(_x: &'a u32, s: &'static u32) -> &'static u32 {
31     let ((y, _z),) = ((s, _x),) as (PairCoupledTypes<_>,);
32     y //~ ERROR lifetime may not live long enough
33 }
34
35 fn cast_coupled_regions_rhs<'a>(_x: &'a u32, s: &'static u32) -> &'static u32 {
36     let ((y, _z),) = ((s, _x),) as (PairCoupledRegions<_>,);
37     y //~ ERROR lifetime may not live long enough
38 }
39
40 fn main() {}