Skip to content

Commit 9cfb5f7

Browse files
committed
add test
1 parent d1743c9 commit 9cfb5f7

File tree

1 file changed

+58
-0
lines changed

1 file changed

+58
-0
lines changed

Diff for: tests/ui/implied-bounds/normalization.rs

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
// Test that we get implied bounds from complex projections after normalization.
2+
3+
// check-pass
4+
5+
// implementations wil ensure that
6+
// WF(<T as Combine<'a>>::Ty) implies T: 'a
7+
trait Combine<'a> {
8+
type Ty;
9+
}
10+
11+
impl<'a, T: 'a> Combine<'a> for Box<T> {
12+
type Ty = &'a T;
13+
}
14+
15+
// ======= Wrappers ======
16+
17+
// normalizes to a projection
18+
struct WrapA<T>(T);
19+
impl<'a, T> Combine<'a> for WrapA<T>
20+
where
21+
T: Combine<'a>,
22+
{
23+
type Ty = T::Ty;
24+
}
25+
26+
// <WrapB<T> as Combine<'a>>::Ty normalizes to a type variable ?X
27+
// with constraint `<T as Combine<'a>>::Ty == ?X`
28+
struct WrapB<T>(T);
29+
impl<'a, X, T> Combine<'a> for WrapB<T>
30+
where
31+
T: Combine<'a, Ty = X>,
32+
{
33+
type Ty = X;
34+
}
35+
36+
// <WrapC<T> as Combine<'a>>::Ty normalizes to `&'a &'?x ()`
37+
// with constraint `<T as Combine<'a>>::Ty == &'a &'?x ()`
38+
struct WrapC<T>(T);
39+
impl<'a, 'x: 'a, T> Combine<'a> for WrapC<T>
40+
where
41+
T: Combine<'a, Ty = &'a &'x ()>,
42+
{
43+
type Ty = &'a &'x ();
44+
}
45+
46+
//==== Test implied bounds ======
47+
48+
fn test_wrap<'a, 'b, 'c1, 'c2, A, B>(
49+
_: <WrapA<Box<A>> as Combine<'a>>::Ty, // normalized: &'a A
50+
_: <WrapB<Box<B>> as Combine<'b>>::Ty, // normalized: &'b B
51+
_: <WrapC<Box<&'c1 ()>> as Combine<'c2>>::Ty, // normalized: &'c2 &'c1 ()
52+
) {
53+
None::<&'a A>;
54+
None::<&'b B>;
55+
None::<&'c2 &'c1 ()>;
56+
}
57+
58+
fn main() {}

0 commit comments

Comments
 (0)